Nest CASE Function in Beast Mode?
Hi,
I am new to Domo and am trying to set up a "nested" case function in Beast Mode (similar to a nested IF statement in Excel and am running into some issues. Can anyone tell me what is wrong with the below example? Many thanks!
CASE when `Car`= Red then '1' else
CASE when `Car`= Green then '2' else
CASE when `Car`= Blue then '3' else ‘4’ End
Comments
-
Because you are referencing strings you have to add delimiters.
So place the colors as such:
'RED'
'BLUE'
'GREEN'
0 -
You have a few syntax errors in the example below. The biggest issue is that you don't need to repeat the "case" portion of the case statement. It should look like this:
- CASE
WHEN `Car` = 'Red' THEN 1
WHEN `Car` = 'Green' THEN 2
WHEN `Car` = 'Blue' THEN 3
ELSE 4
END
I made a few other changes. You needed to have quotes around the colors (red, green and blue). If those were not there Domo would expect to see columns from the data grid with those names. I assumed that you were actually checking for the values red, green and blue in the data set.
I also changed the case statement to return numbers instead of characters.
-----
I work for Domo.
**Say "Thanks" by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as "Accepted Solution"2 - CASE
-
I'm trying to simuluate a nested IF(AND()) as used in excel. is that possible with BeastMode?
IF(AND(var 1= 'A', var2 + var3 > 0),'YES', IF(AND(var1 = 'A', var4 = 'No'),'No','')))
is this possible?
0 -
you would use a case statement and it would look something like this
CASE when `var 1`= 'A' and `var2` + `var3` > 0 THEN 'YES' When `var1` = 'A' and `var4` = 'No' then 'No' else '' end
Domo Arigato!
**Say 'Thanks' by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as 'Accepted Solution'1 -
Why does the following not work?
@cwagnerwrote:Hi,
I am new to Domo and am trying to set up a "nested" case function in Beast Mode (similar to a nested IF statement in Excel and am running into some issues. Can anyone tell me what is wrong with the below example? Many thanks!
CASE when `Car`= Red then '1' else
CASE when `Car`= Green then '2' else
CASE when `Car`= Blue then '3' else ‘4’ Endcase
when (MONTH(`Created Date`)= '1' then 'Jan'
when (MONTH(`Created Date`)= '2' then 'Feb'
when (MONTH(`Created Date`)= '3' then 'Mar'
when (MONTH(`Created Date`)= '4' then 'Apr'
when (MONTH(`Created Date`)= '5' then 'May'
when (MONTH(`Created Date`)= '6' then 'Jun'
when (MONTH(`Created Date`)= '7' then 'Jul'
when (MONTH(`Created Date`)= '8' then 'Aug'
when (MONTH(`Created Date`)= '9' then 'Sep'
when (MONTH(`Created Date`)= '10' then 'Oct'
when (MONTH(`Created Date`)= '11' then 'Nov'
when (MONTH(`Created Date`)= '12' then 'Dec'
end0 -
You don't need to leading parenthesis (and it wasn't being closed). The following should work now.
- case
when MONTH(`Created Date`)= '1' then 'Jan'
when MONTH(`Created Date`)= '2' then 'Feb'
when MONTH(`Created Date`)= '3' then 'Mar'
when MONTH(`Created Date`)= '4' then 'Apr'
when MONTH(`Created Date`)= '5' then 'May'
when MONTH(`Created Date`)= '6' then 'Jun'
when MONTH(`Created Date`)= '7' then 'Jul'
when MONTH(`Created Date`)= '8' then 'Aug'
when MONTH(`Created Date`)= '9' then 'Sep'
when MONTH(`Created Date`)= '10' then 'Oct'
when MONTH(`Created Date`)= '11' then 'Nov'
when MONTH(`Created Date`)= '12' then 'Dec'
end
Sincerely,
ValiantSpur
0 - case
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 7 Cloud Amplifier
- 9 Federated
- 3K Transform
- 114 SQL DataFlows
- 654 Datasets
- 2.2K Magic ETL
- 4.1K Visualize
- 2.5K Charting
- 805 Beast Mode
- 79 App Studio
- 44 Variables
- 761 Automate
- 189 Apps
- 480 APIs & Domo Developer
- 75 Workflows
- 17 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 408 Distribute
- 119 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 141 Manage
- 137 Governance & Security
- 8 Domo Community Gallery
- 47 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive