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.5K Product Ideas
 1.5K Ideas Exchange
 1.4K Connect
 1.1K Connectors
 284 Workbench
 4 Cloud Amplifier
 4 Federated
 2.7K Transform
 90 SQL DataFlows
 570 Datasets
 2K Magic ETL
 3.4K Visualize
 2.4K Charting
 605 Beast Mode
 17 App Studio
 29 Variables
 602 Automate
 152 Apps
 419 APIs & Domo Developer
 29 Workflows
 2 DomoAI
 28 Predict
 12 Jupyter Workspaces
 16 R & Python Tiles
 366 Distribute
 100 Domo Everywhere
 264 Scheduled Reports
 2 Software Integrations
 98 Manage
 95 Governance & Security
 15 Product Releases
 Community Forums
 37 Getting Started
 28 Community Member Introductions
 90 Community Announcements
 4.8K Archive