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
Best Answer
-
@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
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
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 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