Case statement help! :)

ahobson
ahobson Member
edited March 2023 in Datasets

Hi all! I'm not really new to Domo, but definitely new to the community here. I'm trying to build out a case statement to bucket some of my values together. If I do something such as

when `xx field` like '%canada%' then 'canada'

when `xx field` like '%growth%' then 'growth'

If i have values that are something like Canada - Growth, will it put it into Canada because it goes first? Or will it get confused and not know what to do?

Best Answer

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    Hi @ahobson

    Case statements are evaluated from a top down approach and will only evaluate the first true condition it finds. In your case it'll return 'canada' first as that's the first condition that was met to be true and it won't ever return growth.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    Hi @ahobson

    Case statements are evaluated from a top down approach and will only evaluate the first true condition it finds. In your case it'll return 'canada' first as that's the first condition that was met to be true and it won't ever return growth.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Amazing!! That's what I want but was breaking my brain on thinking it through! :) Thank you!