Forum Discussion
Calculate difference between two values in same column
- 4 years ago
Hi, Kadrimedquali
I have simply simulated some data that I hope fits your situation, and you can try the following methods.
Measure = IF ( HASONEVALUE ( 'Table'[Year] ), SUM ( 'Table'[Value] ), CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), [Year] = 2021 && [Category] = SELECTEDVALUE ( 'Table'[Category] ) ) ) - CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), [Year] = 2020 && [Category] = SELECTEDVALUE ( 'Table'[Category] ) ) ) )Change the name of the column Total to Difference. The results are shown in the figure.
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Kadrimedquali
I have simply simulated some data that I hope fits your situation, and you can try the following methods.
Measure =
IF (
HASONEVALUE ( 'Table'[Year] ),
SUM ( 'Table'[Value] ),
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
[Year] = 2021
&& [Category] = SELECTEDVALUE ( 'Table'[Category] )
)
)
- CALCULATE (
SUM ( 'Table'[Value] ),
FILTER (
ALL ( 'Table' ),
[Year] = 2020
&& [Category] = SELECTEDVALUE ( 'Table'[Category] )
)
)
)
Change the name of the column Total to Difference. The results are shown in the figure.
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.