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.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
- 737 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 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
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive