Run rate beastmode calculation
Hi all, trying to formulate a beastmode calculation to give me weekly run rate so I can do a WoW chart. No matter how I modify the query, I keep getting a "Calculation Error : All fields must be aggregated or in the group by clause". This is the first time I am seeing this error. Any insights and advice would be appreciated. Query is below, let me know if there are any glaring flaws that I'm just not seeing.
SUM(CASE WHEN Category
= 'Revenue' AND YEARWEEK(Date
) = YEARWEEK(CURRENT_DATE()) THEN Amount
ELSE 0 END) /
COUNT(DISTINCT CASE WHEN Category
= 'Revenue' AND YEARWEEK(Date
) = YEARWEEK(CURRENT_DATE()) THEN Date
END)
Answers
-
@tmerchant I just tried your beast mode using some sample data, and didn't run into the same error. With that being said, one thing I would recommend is to break your beast mode into parts, and test those parts to figure out where the problem is originating from. For example, take
SUM(CASE WHEN Category = 'Revenue' AND YEARWEEK(Date) = YEARWEEK(CURRENT_DATE()) THEN Amount ELSE 0 END)
and run it by itself. If that works, then do the same for the second part of the beast mode. Once you identify the source, you can do some more digging to figure out what's causing the issue.
The error doesn't really make it sound like this is the issue - but also be sure to check that the columns you're referencing are the correct type. E.g. - Amount is numeric, date is actually a date field.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**0 -
hi @david_cunningham thank you for your reply! tried breaking it up and am immediately running into Calculation Error : Aggregate functions are not allowed in this context: 'SUM'. which is another error I'm seeing for the very first time. I know this is a typical error for WHERE nested within SUM, which isn't the case here. Any idea why this might be?
0 -
@tmerchant this error I would guess is coming from attempting to do the calculation in a Magic ETL formula tile, which does not allow aggregation. It will run in a beastmode on a card as @david_cunningham tested. If you want this to be in a Magic ETL formula, use a Group By tile instead, select the columns groupings and define the formula in that field. Try that and let us know!
Jacob Folsom
**Say “Thanks” by clicking the “heart” in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 731 Beast Mode
- 55 App Studio
- 40 Variables
- 683 Automate
- 175 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 122 Manage
- 119 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 107 Community Announcements
- 4.8K Archive