cancel
Showing results for
Did you mean:  Helper II

## How to calculate difference between two rows in a table?

Hi everyone,

I need your help. I want to calculate the difference of Montant of C and D. Supposingly, I would like to subtract montant of C from montant of D. I want to display Difference i.e- 0.10  instead of total value displayed in third row. Best Regards,

Diksha Gupta

1 ACCEPTED SOLUTION  Community Champion

Hey @gupta_diksha ,

you can subtract one from the other:

``````Difference Montant C to D =
CALCULATE(
SUM( myTable[Montant] ),
myTable[Sens] = "D"
)
- CALCULATE(
SUM( myTable[Montant] ),
myTable[Sens] = "C"
)``````

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

5 REPLIES 5  Super User II

Your two numbers exceed the computational accuracy of Power BI Desktop. I have therefore shortened it a little and added a calculated column for calculation. ``````Subtract =
IF (
HASONEVALUE ( 'Table'[Sens Montant] ),
MIN ( 'Table'[Value] ),
SUMX ( 'Table', 'Table'[Value] * 'Table'[Value Type] )
)
``````

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)  Helper II

Hi Frank,

Thank you for replying. How did you calculate value type column? Could you pls tell it?

Regards  Community Champion

Hey @gupta_diksha ,

you can subtract one from the other:

``````Difference Montant C to D =
CALCULATE(
SUM( myTable[Montant] ),
myTable[Sens] = "D"
)
- CALCULATE(
SUM( myTable[Montant] ),
myTable[Sens] = "C"
)``````

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis  Helper II Hey It worked but why is It 0.13 instead of 0.10?

Thank you  Helper II

Hi , Thank you for replying.

The formula suggested by you is not working fine. Could you please suggest something else instead? Announcements #### Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories. #### Power BI Dev Camp - September 30th, 2021  