Guidance on Proper Beast Mode Syntax for Nested Cases
Hi everyone. I am trying to build-up a series of "cases" that will identify if our shipment is either "Hit", "Miss", or "Risk" in that order. "N/A" if shipment does not satisfy any of the 3.
We have created a logic for each identifier. It is showing as validated but we are not getting the expected results with a lot going to "N/A"
I shared the current beastmode below. Is there anything wrong how I created the logic? Please let me know if further clarification is needed. Thank you so much.
--------------------
Case when`actual arrival at pod date`is not NULL
AND
(DATEDIFF(`actual departure from pod date`,`actual arrival at pod date`) < = `Port free time`)
THEN 'HIT'
when `actual arrival at pod date` is not NULL
AND
(DATEDIFF(`actual departure from pod date`,`actual arrival at pod date` ) > `Port free time`)
OR
`actual arrival at pod date` is not NULL
AND
(DATEDIFF(`current date`,`actual arrival at pod date` ) > `Port free time`)
THEN 'MISS'
when `actual arrival at pod date` is not Null
AND
`actual departure from pod date` is NULL
AND
(DATEDIFF(`current date`,`actual arrival at pod date`) > = 3)
AND
(DATEDIFF(`current date`,`actual arrival at pod date` ) < `Port free time`)
Then 'Risk'
Else 'N/A'
END
Answers
-
@arzconci Without seeing your actual data and results, the first thing that stands out to me is the OR in your criteria for 'MISS'. When you are using OR operators, be sure to use parenthesis to group relevant criteria. For example, if both of the statements before and after the OR must be true, then it should look like this:
when ( `actual arrival at pod date` is not NULL AND (DATEDIFF(`actual departure from pod date`,`actual arrival at pod date` ) > `Port free time`) ) OR ( `actual arrival at pod date` is not NULL AND (DATEDIFF(`current date`,`actual arrival at pod date` ) > `Port free time`) ) THEN 'MISS'
2 -
@MichelleH Thank you for the advise Michelle! Noted and will update my DOMO logic on it. Sorry, basic question, how do you paste Beast Mode syntax in that format?
0 -
Alternatively you can use can type ``` and a code block will pop up for you.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Thanks Michelle and Grant.
Anyways, going back to the original topic, for the "Miss", @MichelleH, there are actually only 2 groups of conditions. I need to have output as Miss if either lines 1-5 or 9-13 is satisfied. So based on your advice, I can also just group them via parenthesis? Sample below
( when `actual arrival at pod date` is not NULL AND (DATEDIFF(`actual departure from pod date`,`actual arrival at pod date` ) > `Port free time`) ) OR ( `actual arrival at pod date` is not NULL AND (DATEDIFF(`current date`,`actual arrival at pod date` ) > `Port free time`) ) THEN 'MISS'
0
Categories
- 7.7K All Categories
- 7 Connect
- 922 Connectors
- 245 Workbench
- 477 Transform
- 1.8K Magic ETL
- 60 SQL DataFlows
- 446 Datasets
- 57 Visualize
- 205 Beast Mode
- 2.1K Charting
- 8 Variables
- 4 Automate
- 349 APIs & Domo Developer
- 84 Apps
- Workflows
- 15 Predict
- 3 Jupyter Workspaces
- 12 R & Python Tiles
- 242 Distribute
- 60 Domo Everywhere
- 241 Scheduled Reports
- 15 Manage
- 36 Governance & Security
- 43 Product Ideas
- 1.1K Ideas Exchange
- 3 Community Forums
- 16 Getting Started
- 3 Community Member Introductions
- 50 Community News
- 18 Event Recordings
- 576 日本支部