Forum Discussion
Compute difference between Subtotals
- 6 years ago
Right, again, no sample data so can't be specific. Hint.
But, in general, you want to do this. Take a look at your visual and see how it is aggregated. Let's say it is by "Thing". You want to create a virtual table using a VAR that emulates this and your columns. Then use SUMX and basic math. Something like this:
Subtotal Difference = VAR __Table = SUMMARIZE( 'Table', [Thing], "2019",SUM([2019), "2020",SUM([2020) ) RETURN SUMX(__Table,[2019]) - SUMX(__Table,[2020])
These are column aggregations. I want to calculate the differenence between these 2 subtotals. How can i add a measure to calculate this?
Right, again, no sample data so can't be specific. Hint.
But, in general, you want to do this. Take a look at your visual and see how it is aggregated. Let's say it is by "Thing". You want to create a virtual table using a VAR that emulates this and your columns. Then use SUMX and basic math. Something like this:
Subtotal Difference =
VAR __Table =
SUMMARIZE(
'Table',
[Thing],
"2019",SUM([2019),
"2020",SUM([2020)
)
RETURN
SUMX(__Table,[2019]) - SUMX(__Table,[2020])