SubTotal Category Remaining Amount: How to calculate difference between two columns
How to display the value of "Remaining Amount' in subtotal category:
I have the following scenario, using a Pivot table Displaying the budget amount and actual amount along with remaining amount.
for every subcategory I do not want to display remaining amount if either value budget or Actual value is 0.
However I will still like to display a value for remaining amount if either the Budget or Actual value exist (My understanding is that I the value rolls up and adds to display subtotal values).
Below is the formula's I used to calculate Remaining Amount in BeastMode calculation.
CASE
when
sum(case when `Transaction_Type` = 1 then `Amount` else 0 end) =0
or
sum(case when `Transaction_Type` = 0 then `Amount` else 0 end) =0
then 0
else
sum(case when `Transaction_Type` = 1 then `Amount` else 0 end)
-
sum(case when `Transaction_Type` = 0 then `Amount` else 0 end)
end
Thank you
~Monika
Answers
-
Hi,
Instead of 0 in your code can you put '' in the beast mode. So if budget or actual value is 0 then '' .
Does that give you what you need?
Thanks
0 -
Hi @msharma
Because the way pivot tables behave and the fact that subtotals are an all or nothing setting what you're looking to do isn't possible at this time.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
@msharma ,
@rahul93 is partially correct, if you put a '' in your ELSE clause you will convert your beastmode into a string. It therefore wouldn't format or behave like a number after that point. probably not desireable.
To get 'nothing' as Rahul is recommending, you can however use ELSE NULL
sum(case when `Transaction_Type` = 1 then `Amount` else null end) -- or sum(case when `Transaction_Type` = 1 then `Amount` end) =0
Now that said you have to be careful with null
if you take
5 - NULL
the result witll be NULL
@GrantSmith talks about this at the IDEAS Exchange Conference, https://www.youtube.com/watch?v=gO8OLpsAk4M&list=PLUy_qbtzH0S6-5oDbx3BsIv2Xk-JxJxWi&index=6
SOLUTION
test if your amounts net to 0 if so replace with null
case when sum(case when ... then amount else 0 end) - sum(case when ... then budget else 0 end) = 0 then null else sum(case when ... then amount else 0 end) - sum(case when ... then budget else 0 end) end
THAT SAID. WHAT YOU'RE ASKING FOR IS LOGICALLY INAPPROPRIATE
Null and 0 are not the same thing.
If i had 5 dollars and spent 5 dollars i have zero dollars left.
That's different from I spent nothing and i had no budget therefore the value should be null.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Hi, using a '' doesn't convert the field into a string field. I just tested it and it works as a numeric field. See screenshots
Thanks
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