doing case when like statements in datameer?

5 followers
0
Avatar

How do you do case when like statements in datameer? Something like this:

case
when 1 then a
when 2 then b
when 3 then c
else d
end

Ronak Patel2

5 comments

  • Avatar
    Frances Angulo

    You can create nested IF statements using syntax like:

    IF(#Sheet!Column>90;"A";IF(#Sheet!Column<20;"F"; "Average"))

    You can also use "IF(AND" combinations to define ranges. Operators mentioned here are 'greater than' and 'less than' but you can also use '=' and '=='. I believe this syntax also accepts pipes (||) for OR statements.

    1
  • Avatar
    Frances Angulo

    At first attempt, I didn't have success using a wild card in my formula. I think what might be appropriate, depending on your use case, would be to use something like REGEXTRACT or REGEX functions- which would give you the flexibility to pull certain results on conditions with that syntax.

    0
  • Avatar
    Chad Hult

    Frances Angulo are you mixing data types in the statement?  90 integer, "A" string.

    From what I have seen this won't work???  Or have did you get mixed data types working somehow?

    IF(#Sheet!Column>90;"A";IF(#Sheet!Column<20;"F"; "Average"))

    Curious.  Thanks

    0
  • Avatar
    Joel Stewart

    In Frances's example, the data type for the #Sheet!Column is an Integer. That said, the statement #Sheet!Column>90 is a Boolean type which is required for the first parameter of the IF function. Continuing in the example, the output in all cases is a String (i.e. "A", "F", "Average"). As long as the output is all the same data type, the IF statement is valid. 

    Hopefully, that clears things up! 

     

    0
Please sign in to leave a comment.