I am trying to build a beast mode that compares Quarter over Quarter.
This is the formula I am using but it keeps telling me Invalid Formula : This calculation contained a syntax error.
These are my headers:
The first part is how I got QTR Lbs. I would like to compare the differences Quarter over Quarter and then format it in percentage.
I am not sure what the error is.
(SUM((CASE WHEN ((YEAR(`StartDate`)=YEAR(CURRENT_DATE())) AND (QUARTER(`StartDate`)=QUARTER(CURRENT_DATE()))) THEN `LBS` ELSE 0 END )) and
(case
when right(`CurrentMonth`,2)-0 = '1' then 'Q01'
when right(`CurrentMonth`,2)-0 = '2' then 'Q01'
when right(`CurrentMonth`,2)-0 = '3' then 'Q01'
when right(`CurrentMonth`,2)-0 = '4' then 'Q02'
when right(`CurrentMonth`,2)-0 = '5' then 'Q02'
when right(`CurrentMonth`,2)-0 = '6' then 'Q02'
when right(`CurrentMonth`,2)-0 = '7' then 'Q03'
when right(`CurrentMonth`,2)-0 = '8' then 'Q03'
when right(`CurrentMonth`,2)-0 = '9' then 'Q03'
when right(`CurrentMonth`,2)-0 = '10' then 'Q04'
when right(`CurrentMonth`,2)-0 = '11' then 'Q04'
when right(`CurrentMonth`,2)-0 = '12' then 'Q04'
else 'Other' end))
-
(SUM((CASE WHEN ((YEAR(`StartDate`)=YEAR(CURRENT_DATE())) AND (QUARTER(`StartDate`)=QUARTER(CURRENT_DATE()))) THEN `LBS` ELSE 0 END )) and
(case
when right(`CurrentMonth`,2)-0 = '1' then 'Q01'
when right(`CurrentMonth`,2)-0 = '2' then 'Q01'
when right(`CurrentMonth`,2)-0 = '3' then 'Q01'
when right(`CurrentMonth`,2)-0 = '4' then 'Q02'
when right(`CurrentMonth`,2)-0 = '5' then 'Q02'
when right(`CurrentMonth`,2)-0 = '6' then 'Q02'
when right(`CurrentMonth`,2)-0 = '7' then 'Q03'
when right(`CurrentMonth`,2)-0 = '8' then 'Q03'
when right(`CurrentMonth`,2)-0 = '9' then 'Q03'
when right(`CurrentMonth`,2)-0 = '10' then 'Q04'
when right(`CurrentMonth`,2)-0 = '11' then 'Q04'
when right(`CurrentMonth`,2)-0 = '12' then 'Q04'
else 'Other' end))
/
(SUM((CASE WHEN ((YEAR(`StartDate`)=YEAR(CURRENT_DATE())) AND (QUARTER(`StartDate`)=QUARTER(CURRENT_DATE()))) THEN `LBS` ELSE 0 END )) and
(case
when right(`CurrentMonth`,2)-0 = '1' then 'Q01'
when right(`CurrentMonth`,2)-0 = '2' then 'Q01'
when right(`CurrentMonth`,2)-0 = '3' then 'Q01'
when right(`CurrentMonth`,2)-0 = '4' then 'Q02'
when right(`CurrentMonth`,2)-0 = '5' then 'Q02'
when right(`CurrentMonth`,2)-0 = '6' then 'Q02'
when right(`CurrentMonth`,2)-0 = '7' then 'Q03'
when right(`CurrentMonth`,2)-0 = '8' then 'Q03'
when right(`CurrentMonth`,2)-0 = '9' then 'Q03'
when right(`CurrentMonth`,2)-0 = '10' then 'Q04'
when right(`CurrentMonth`,2)-0 = '11' then 'Q04'
when right(`CurrentMonth`,2)-0 = '12' then 'Q04'
else 'Other' end))
Answers
-
Hi @Rvannoy
What is this section of code doing?
and (case when right(`CurrentMonth`,2)-0 = '1' then 'Q01' when right(`CurrentMonth`,2)-0 = '2' then 'Q01' when right(`CurrentMonth`,2)-0 = '3' then 'Q01' when right(`CurrentMonth`,2)-0 = '4' then 'Q02' when right(`CurrentMonth`,2)-0 = '5' then 'Q02' when right(`CurrentMonth`,2)-0 = '6' then 'Q02' when right(`CurrentMonth`,2)-0 = '7' then 'Q03' when right(`CurrentMonth`,2)-0 = '8' then 'Q03' when right(`CurrentMonth`,2)-0 = '9' then 'Q03' when right(`CurrentMonth`,2)-0 = '10' then 'Q04' when right(`CurrentMonth`,2)-0 = '11' then 'Q04' when right(`CurrentMonth`,2)-0 = '12' then 'Q04' else 'Other' end))
You're returning a string but not comparing it to anything and subtracting that value from a number. Can this section be removed?
Typically when I'm running into errors I'll take out sections of my beast mode until it works (or inversely start basic and keep adding to it to see when it errors). Domo beast mode errors aren't very helpful sadly.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
It looks as though you are trying to sum the lbs field with the string values: Q01, Q02, etc. You can't sum string values. That is probably where you error is occurring.
**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 -
That coding is telling it what quarter return (Q1, Q2, ect...).
I have tried it with and without this particular string. I will keep working at it.
0 -
Right now, you have it coded as a string. If your datasets has columns called Q1, Q2, etc. then you could have those in your case statement, but you need to fix that in your statement so it is actually referencing those fields. If Q1, Q2 are calculations, you would need the actual calculation in your case statement.
**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 -
To simplify your approach I'd recommend using a date offset dimension dataset and utilizing that to calculate period over period calculations. I did a whole writeup of it here: https://dojo.domo.com/discussion/53481/a-more-flexible-way-to-do-period-over-period-comparisons#latest
If you would like to continue down your beast mode route I recommend breaking up your beast mode into the current value and the last year value and plot them on a table graph to make sure they're calculating correctly, if that's the case then go ahead and create a new beast mode to then drag and drop your current value and last quarter value beast modes in with the format:
( CURRENT - LAST ) / LAST
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 747 Beast Mode
- 59 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
- 396 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 126 Manage
- 123 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive