Beast mode calculation
I want to create a beast mode calculation which should be something like this
Value for current month this year - value for current month last year / Value for current month last year
How can i do this?
Answers
-
@domoexpert You can accomplish this using a case statement within an aggregate for each value in your calculation. It should look something like this:
(sum(case when LAST_DAY(`DateField`) = LAST_DAY(CURRENT_DATE()) then `ValueField` end) - sum(case when LAST_DAY(`DateField`) = LAST_DAY(DATE_SUB(CURRENT_DATE(),interval 1 year)) then `ValueField` end)) / sum(case when LAST_DAY(`DateField`) = LAST_DAY(DATE_SUB(CURRENT_DATE(),interval 1 year)) then `ValueField` end)
0 -
Is there a way to do it other than current date since the data is lagged and might not be up to current date. Any way to do it for max month thats available
0 -
@domoexpert Yes, you could do that. In that case I'd recommend creating a "Max Date" column in your dataset using the Group by ETL tile to use instead of CURRENT_DATE()
0 -
Can that not be done in beast mode?
0 -
@domoexpert You can try using MAX(`DateField`) instead of CURRENT_DATE() in the beast mode, though it's possible the Max Date could change if you apply filters to the card. I have also found that using an aggregate (MAX) inside another aggregate (SUM) is less reliable in beast mode
0 -
((CASE WHEN YEAR(`Date`) = MAX(YEAR(`Date`)) and MONTH(`Date`) = MAX(MONTH(`Date`)) THEN SUM(`Value`) END) -
(CASE WHEN YEAR(`Date`) = MAX(YEAR(`Date`))-1 and MONTH(`Date`) = MAX(MONTH(`Date`)) THEN SUM(`Value`) END))
/
(CASE WHEN YEAR(`Date`) = MAX(YEAR(`Date`))-1 and MONTH(`Date`) = MAX(MONTH(`Date`)) THEN SUM(`Value`) END)I am doing this but this is giving me an error
0 -
What kind of card are you trying to use and what does the raw data look like? Some cards in Domo come pre-built with Period over Period capabilities that would take care of showing this for you without the need of any BeastMode, this works great specially if your data for each month is calculated by the default Group By configuration of the Date Range.
Depending on your needs you might want to do a view first that summarizes things at a monthly level and use a lag function and use a lag function and filters on your beast mode to get what you want.
0 -
What type of visualization are you using? You can accomplish this with the Period over Period "Variance bar line" chart type:
1 -
I am trying to build a simple table calculation.
0 -
If you used a variable to set the current month and comparison month, then you could write a beastmode to get this calculation. But then the user would need to set those values when they view the card. (you can select a default value, but unfortunately the default can't be "current month". You would need to update the default selections each month)
1 -
The real question is that why isnt the above calculation working?
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