Magic ETL

Magic ETL

If condition between two columns

Hello, could you help me with a calculation to create a new column in my table: If the "Fixed Value" column has a value, add "Fixed Contract" but if the "Spot" column has a value, put "Spot Contracts" in the newly created column.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answers

  • edited May 2024 Answer ✓
    1. case
    2. when Fixed Value is not null then "Fixed Contract"
    3. when Spot is not null then "Spot Contract"
    4. else "Undefined"
    5. END

    I don't have your actual data, so this is assuming that there is never a time when both "Fixed Value" and "Spot" are both populated, and that you don't have to check any other conditions. I threw in an ELSE to catch other cases.

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

  • Coach
    Answer ✓

    @DanieleSilva You can use the following case statement either in Beast Mode or an ETL formula tile:

    1. case
    2. when `Fixed Value` is not null then 'Fixed Contract'
    3. when `Spot` is not null then 'Spot'
    4. end

Answers

  • edited May 2024 Answer ✓
    1. case
    2. when Fixed Value is not null then "Fixed Contract"
    3. when Spot is not null then "Spot Contract"
    4. else "Undefined"
    5. END

    I don't have your actual data, so this is assuming that there is never a time when both "Fixed Value" and "Spot" are both populated, and that you don't have to check any other conditions. I threw in an ELSE to catch other cases.

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

  • Coach
    Answer ✓

    @DanieleSilva You can use the following case statement either in Beast Mode or an ETL formula tile:

    1. case
    2. when `Fixed Value` is not null then 'Fixed Contract'
    3. when `Spot` is not null then 'Spot'
    4. end
  • Thank you for sending this and sorry for the delay. This is my first time using DOMO, so I may be doing something wrong because I couldn't do it. I would like to know which ETL option I should use to create the "Fixed Contract" and "Spot Contract" columns. The columns I have as Fixed Value and Spot (BRL) are numeric.

  • @DanieleSilva

    You would use the Formula Tile in MagicETL and then use the code provided above. You can name this column whatever you want.

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

  • Thanks David! It worked!

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In