Error when creating a case statement for a data flow column
What am I doing incorrect?
It gives me an error while using the case statement.
Answers
-
I think all you need to do is have a space between CASE and your fieldname 'WPS Score'. It looks like they are together so Domo can't read it correctly.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
I tried again with changed syntax, but again same error.
0 -
Actually, after trying a similar statements, you can't do a < or IN statement like that. You need to write it like this:
(CASE WHEN `wps score` < 6 THEN 'Detractor' WHEN `wps score` < 8 THEN 'Passive' ELSE 'Promoter' END)
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
But then what happens for values between 6 to 8, because in 2nd statement anything under 8 will flag as passive, but I want them as detractors and only between 6-8 as passive
0 -
Case statements exit after finding a match so you don't need to do a between or in statement. If, for example, your score is 7, it will evaluate the first line and since it is not less than 6, it will go to next when statement and see if it evaluates as true. It would then exit out after evaluating a true being less than 8 and be labeled as passive. If the value is 4, it would exit after the first statement and be labeled as a detractor.
The key is just to stack your when statements in order, from lowest to highest in this case, for the evaluations to work. If you changed the order, and just put them in "randomly" you would get undesirable results.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1 -
So Just for understanding, why can I not use IN statement in this syntax?
because I saw a similar application of IN statement in documentation here
0 -
If you wanted to use an IN operator, your WHEN line would need to look like this:
WHEN `wps score` IN (6,7) THEN 'Passive'
IN clauses hold a list of values. You can't use greater than or less than operators within the list.
You can technically use whatever is most readable to you and others that would need to understand the beast mode function.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
So basically its because "<" or ">" operator are not supported for IN statement?
Also I noticed that you had a parenthesis before CASE and after the END. does case statement needs to be in parenthesis?
1 -
That is correct about the "<" and ">" in the IN statement.
The parentheses are optional around the CASE statement. Domo automatically adds them when you start typing in the formula editor and use the auto-complete option.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
@user026529 if you can accept answer and/or like any of the above responses that will help others in the community as they search for similar questions.
Hoped all of this helped!
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
@MarkSnodgrass kudos for the mega patient answers! I love that.
@user026529 , altthough Beast Modes ARE NOT executed in MySQL they do generally follow MySQL syntax. If you're encountering a Syntax error, just google your function + MySQL and it will generally accurately describe the syntax you're supposed to use.
There are some small exceptions... but there you go.
No you don't have to wrap a CASE inside of parenthesis. Assume that each Beast Mode must be a syntactically correct argument in a SELECT clause.
I.E.
SELECT
CASE WHEN ... END
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Thanks. I realized that my syntax error was because I was using IN with WHEN. The moment I removed IN the error went away, but the way DOMO described the error was kind of misleading and not helpful. It should have created an error on IN statement.
0 -
@user026529 , the IN argument works fine in a CASE statement in Magic 2.0 formula tile. just tested. Use MySQL syntax.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Then what was the meaning of the error as in the screenshot?
0 -
@user026529 The error message could use some improvement, but it doesn't like the when <6 statement and it doesn't like your arguments in the In statement.
You need to write it how I suggested earlier, which was:
(CASE WHEN `wps score` < 6 THEN 'Detractor' WHEN `wps score` < 8 THEN 'Passive' ELSE 'Promoter' END)
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 744 Beast Mode
- 58 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 395 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 6 Software Integrations
- 125 Manage
- 122 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive