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:
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman1 -
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)
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman1 -
The real question is that why isnt the above calculation working?
0
Categories
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 294 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.8K Transform
- 97 SQL DataFlows
- 607 Datasets
- 2.1K Magic ETL
- 3.8K Visualize
- 2.4K Charting
- 707 Beast Mode
- 49 App Studio
- 39 Variables
- 667 Automate
- 170 Apps
- 446 APIs & Domo Developer
- 44 Workflows
- 7 DomoAI
- 33 Predict
- 13 Jupyter Workspaces
- 20 R & Python Tiles
- 391 Distribute
- 111 Domo Everywhere
- 274 Scheduled Reports
- 6 Software Integrations
- 115 Manage
- 112 Governance & Security
- Domo Community Gallery
- 31 Product Releases
- 9 Domo University
- 5.3K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 103 Community Announcements
- 4.8K Archive