When using formulas in SuiteAnalytics Data Sets, h...
# ask-stanley-ai
r
When using formulas in SuiteAnalytics Data Sets, how do I have a CASE statement check for multiple values? I am getting a syntax error using "case when {field} in ('123','456') then 'do something' else 'do something else' end"
c
AI generated answer (using internal Slack threads):
In SuiteAnalytics, you can use multiple conditions in a CASE statement. However, the syntax you're using seems to be incorrect. The correct syntax for a CASE statement with multiple conditions is as follows:
Copy code
CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
...
ELSE resultN
END
Each condition is checked in the order they are written. When a condition is met, the corresponding result is returned and the remaining conditions are not checked. If none of the conditions are met, the result in the ELSE clause is returned. In your case, you should write your formula like this:
Copy code
CASE
WHEN {field} = '123' THEN 'do something'
WHEN {field} = '456' THEN 'do something'
ELSE 'do something else'
END
If you want to check if a field is in a list of values, you can use the OR operator:
Copy code
CASE
WHEN {field} = '123' OR {field} = '456' THEN 'do something'
ELSE 'do something else'
END
Remember to validate your formula in SuiteAnalytics. It has a formula checker that can help you find any syntax errors. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.87564677
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.868486106
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.867851
Please provide your feedback on this answer.