Create custom column based on condition

I am able to do this in SQL but cant figure how to do this using the UI create column feature

Here is scenario

SELECT item_count, created_on,
WHEN item_count < 1 THEN 'Failure'
ELSE 'Success'
END AS ResultDescription
FROM account_session
GROUP BY created on;

Please can any help on how to write conditonal expressions with the create column feature

Hi @watchnerd
You can use case function for Custom Columns:
case([item_count] < 1, "Failure", "Success")

1 Like

@flamber amazing! thanks for the quick response! Loving my experience so far

Hi @flamber :slightly_smiling_face:

Sorry to bring up the conversation when it's closed from last year, but I have a follow up question with the case function.

I'm trying to use it in a custom column to group different User IDs. What I was trying is:
=case( [user ID] contains (12424, 12555, 456567), "Group 1", "Group 2")
With this, these 3 user IDs would be grouped in Group 1 and the rest of user IDs would be grouped in Group 2. I also tried IN and = instead of contains but anything works.

Can you help me with this? Thanks!!

@sandragrabulosa you would have to do something like case([field] = "value1" OR [field] = "value2", "foo", "bar") nested with the "contains" function

1 Like

Amazing!!! Thank you so much :hugs: