Beastmode Error  An issue has occurred during processing.
I am trying to create a simple beastmode to calculate the last week vs 6 week weekly average variance with the calculation below and I keep getting this error message. I've tried troubleshooting but I can't figure out why this isn't working. Can someone help me look into this?
CASE WHEN SUM(CASE WHEN Year Scenario Rolling
= 'This Year' AND Fiscal Week Index
= (Current Week Index
 1) THEN IFNULL(Orders
,0) ELSE 0 END)>0 THEN
(SUM(CASE WHEN Year Scenario Rolling
= 'This Year' AND Fiscal Week Index
= (Current Week Index
 1) THEN IFNULL(Amount_Sales
,0) ELSE 0 END)
/
SUM(CASE WHEN Year Scenario Rolling
= 'This Year' AND Fiscal Week Index
= (Current Week Index
 1) THEN IFNULL(Orders
,0) ELSE 0 END))
/
(CASE WHEN SUM(CASE WHEN Year Scenario Rolling
= 'This Year' AND Fiscal Week Index
> (Current Week Index
 8) AND Fiscal Week Index
< (Current Week Index
 1) THEN IFNULL(Orders
,0) ELSE 0 END)>0 THEN
(SUM(CASE WHEN Year Scenario Rolling
= 'This Year' AND Fiscal Week Index
> (Current Week Index
 8) AND Fiscal Week Index
< (Current Week Index
 1) THEN IFNULL(Amount_Sales
,0) ELSE 0 END)
/
SUM(CASE WHEN Year Scenario Rolling
= 'This Year' AND Fiscal Week Index
> (Current Week Index
 8) AND Fiscal Week Index
< (Current Week Index
 1) THEN IFNULL(Orders
,0) ELSE 0 END)) ELSE 0 END)  1 END
Best Answers

I agree with @marcel_luthi that the issue is likely caused by the nested aggregation and that it would be helpful to see a sample of the data. I'd also suggest summarizing the logic you used to create the beast mode in words so we can point you in the right direction.
3 
@MichelleH said what I was going to say. It can't handle aggregates of aggregates. I find that putting the sum outside the case logic often solves this issue. Think of your case statement as a filter, and then aggregate the results.
I also recommend breaking it apart and reviewing the results of each portion of the beast mode to see where you may need to rearrange the logic. It's basically algebra, so you need to figure out the basic components and and arrange them so that the order of operations is clear and as concise as possible.
DataMaven
Breaking Down Silos  Building Bridges
**Say "Thanks" by clicking a reaction in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1
Answers

Hmm…
• Make sure all parentheses are properly closed and all function names are correctly spelled.
• Make sure the data fields you're referencing exist in your dataset and are named correctly.
• Make sure Current Week Index is a valid reference.
• Division by Zero: Make sure denominators are not zero, as division by zero is undefined. This could happen if there are no orders in the specified weeks. Possible use of coalesce when conditions are null.
• Check if the conditions used in your SUM functions are correctly filtering the data for the weeks you're using.** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **1 
What is the error message you are getting? Can you share mock data with the columns you have and what the calculation would be if you perform it manually? The reason I'm asking is that you have nested aggregation functions (SUM of a SUM) without any window clause (OVER or FIXED) which is odd, so perhaps the formula could be simplified once we understand what the desired calculation is explained in words with an example.
3 
I agree with @marcel_luthi that the issue is likely caused by the nested aggregation and that it would be helpful to see a sample of the data. I'd also suggest summarizing the logic you used to create the beast mode in words so we can point you in the right direction.
3 
@MichelleH said what I was going to say. It can't handle aggregates of aggregates. I find that putting the sum outside the case logic often solves this issue. Think of your case statement as a filter, and then aggregate the results.
I also recommend breaking it apart and reviewing the results of each portion of the beast mode to see where you may need to rearrange the logic. It's basically algebra, so you need to figure out the basic components and and arrange them so that the order of operations is clear and as concise as possible.
DataMaven
Breaking Down Silos  Building Bridges
**Say "Thanks" by clicking a reaction in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1 
I opened the card today and the beastmode is now working on the card. I'm not sure why it wasn't working last week, but I appreciate all of your input! Thank you!
1
Categories
 All Categories
 1.6K Product Ideas
 1.6K Ideas Exchange
 1.5K Connect
 1.2K Connectors
 288 Workbench
 4 Cloud Amplifier
 7 Federated
 2.8K Transform
 94 SQL DataFlows
 590 Datasets
 2.1K Magic ETL
 3.6K Visualize
 2.4K Charting
 662 Beast Mode
 38 App Studio
 34 Variables
 641 Automate
 163 Apps
 433 APIs & Domo Developer
 42 Workflows
 3 DomoAI
 31 Predict
 12 Jupyter Workspaces
 19 R & Python Tiles
 378 Distribute
 107 Domo Everywhere
 266 Scheduled Reports
 5 Software Integrations
 108 Manage
 105 Governance & Security
 8 Domo University
 23 Product Releases
 Community Forums
 39 Getting Started
 29 Community Member Introductions
 94 Community Announcements
 4.8K Archive