Beastmode Error - An issue has occurred during processing.

Options

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

  • MichelleH
    MichelleH Coach
    Answer ✓
    Options

    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.

  • DataMaven
    DataMaven Coach
    Answer ✓
    Options

    @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"

Answers

  • ArborRose
    Options

    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! **

  • marcel_luthi
    marcel_luthi Coach
    edited March 4
    Options

    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.

  • MichelleH
    MichelleH Coach
    Answer ✓
    Options

    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.

  • DataMaven
    DataMaven Coach
    Answer ✓
    Options

    @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"
  • Anna_Otake
    Options

    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!