YoY Beast Mode Issue - "Issue Occurred While Processing"
Hello,
I'm relatively new to Beast Mode within DOMO and am running into issues trying to build a year-over-year calculation. I've built the below script, which was accepted by Beast Mode but is now giving me a "an issue has occured during processing" error. Any ideas on how I could fix this?
CASE WHEN `Actual Revenue` = 0 THEN 0
ELSE
(sum(case
when year(`Line Item Date`) = year(curdate())
then `Actual Revenue`else 0 end)
-
sum(case
when year(`Line Item Date`) = year(curdate())-1 and week(`Line Item Date`) <= week(curdate())
then `Actual Revenue` else 0 end))
/
(sum(case
when year(`Line Item Date`) = year(curdate())-1 and week(`Line Item Date`) <= week(curdate())
then `Actual Revenue` else 0 end))
END
Comments
-
The trouble you're seeing may be due to a combination of different levels of granularity in the beast mode calculation. The first line in the code is looking at a single record in the dataset, but lines below it are looking at a group of records being aggregated together using a SUM function.
Try wrapping a SUM around your `Actual Revenue` on line 1 to keep it at the same level of granularity.
Let us know if that helps!
1 -
Hey @user07803,
At a glance, the issue with your beast mode is the initial CASE statement.
CASE WHEN `Actual Revenue` = 0 THEN 0
Beast mode gets pretty disagreeable when you try to mix row level calcs (non aggregated) with set level calcs (aggregated).
You could add the first beast mode as a component of each of the other case statements. For example:
SUM(Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate()) then `Actual Revenue`
else 0 end)
See if this gets you anywhere.
Best of luck!
**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 -
Thanks. I implemented your script and am now getting a divide by zero error.
(SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate()) then `Actual Revenue`
else 0 end)
-
SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate())-1 then `Actual Revenue`
else 0 end))
/
SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate())-1 then `Actual Revenue`
else 0 end)0 -
You just need to add a check for situations where your denomintor may be 0 or null. For example you could modify your code like this:
CASE
WHEN SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate())-1 then `Actual Revenue`
else 0 end) > 0 THEN(SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate()) then `Actual Revenue`
else 0 end)
-
SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate())-1 then `Actual Revenue`
else 0 end))
/
SUM (Case when `Actual Revenue` = 0 then 0
when year(`Line Item Date`) = year(curdate())-1 then `Actual Revenue`
else 0 end)END
This would only run the calculation when the denominator is > 0. Otherwise it will return a null value. If you'd rather have it return a 0 or some other number, just add an ELSE clause before the final end.
I hope that helps!
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
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive