Percentage Summary Number using Beast Mode
I have a graph that displays my company's net income vs. our budget. In order to calculate the net income, I use the following beast mode:
sum(case when `Group 2 Name` = 'Sales' or `Group 2 Name` = 'Sales Returns' then `Amount` when `Group 2 Name` = 'Direct Costs' or `Group 2 Name` = 'Protein Powder' then -1 * `Amount` when `Group 0 Name` = 'Other Income/Expense' then `Amount` else -1 * `Amount` end)
My budget is stored in a field called:
Net Income (b)
To generate the summary number, I did the following, but for some reason it returns 0%:
sum(case when `Group 2 Name` = 'Sales' or `Group 2 Name` = 'Sales Returns' then `Amount` when `Group 2 Name` = 'Direct Costs' or `Group 2 Name` = 'Protein Powder' then -1 * `Amount` when `Group 0 Name` = 'Other Income/Expense' then `Amount` else -1 * `Amount` end) / sum(`Net Income (b)`)
What am I missing? It might be worth noting that multiplying by 100 did nothing, it still returns 0.
Comments
-
Hi @user060355
Without seeing your data - How is your budget structured? Is that a yearly, monthly or daily budget?
You're likely comparing apples to oranges in terms of your unit of measurement. The numerator is likely on a daily basis but your budget is probably on a non-daily scale.
You'll want to either utilize a MIN function instead of a SUM to pull the budget amount (assuming the data you have is for the same date range (days) as it it in budget (You couldn't have two separate budget values if you're looking at two years worth of data as it'd use the same budget number for those two years)
The better option would be to utilize a windowing function (talk to your CSM if you don't have this enabled in your instance - it's a feature switch) to calculate the minimum budget over the timeframe your budget is defined as.
MIN(MIN(`Net Income (b)`)) OVER(PARTITION BY YEAR(`Date`))
You could use that as your denominator. Again, this is all assuming your `Amount` field is recorded on a daily basis but your budget is on a non-daily basis (like yearly in the example beast mode above).
A helpful tip: Whenever I'm running into issues with a percentage I'll create two separate beast modes, one for the numerator (top) and one for the denominator (bottom) and see what numbers are being returned to see if anything is looking odd. This helps diagnose issues I typically have.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
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
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 748 Beast Mode
- 59 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 396 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 125 Manage
- 122 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive