Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sonaliverma
Advocate I
Advocate I

Subtract rows of same column in PowerBI

Hello ,

 

sonaliverma_1-1643819042020.png

 

As you can see, I have created a Matrix in PowerBI. I want to subtract  (010-020). 

 

Could anyone help me with this issue?

 

Thanks in advance

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @sonaliverma ,

 

you can create sub totals for each value with variables and then subtract them.

The following approach should work:

My Total Measure =
VAR v010Value =
    CALCULATE (
        SUM ( myTable[myValue] ),
        myTalbe[Value Type for Reporting] = '010'
    )
VAR v020Value =
    CALCULATE (
        SUM ( myTable[myValue] ),
        myTalbe[Value Type for Reporting] = '020'
    )
RETURN
    v010Value - v020Value

 

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

Blog: WhatTheFact.bi

View solution in original post

4 REPLIES 4
selimovd
Super User
Super User

Hey @sonaliverma ,

 

you can create sub totals for each value with variables and then subtract them.

The following approach should work:

My Total Measure =
VAR v010Value =
    CALCULATE (
        SUM ( myTable[myValue] ),
        myTalbe[Value Type for Reporting] = '010'
    )
VAR v020Value =
    CALCULATE (
        SUM ( myTable[myValue] ),
        myTalbe[Value Type for Reporting] = '020'
    )
RETURN
    v010Value - v020Value

 

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

Blog: WhatTheFact.bi

Thank you so much @selimovd , worked like a charm!

amitchandak
Super User
Super User

@sonaliverma , You have create a measure for that, Row operation is not possible in power bi

 

M1=

calculate(sum(Table[Value]), filter(Table, Table[Value Type] ="001")) -

calculate(sum(Table[Value]), filter(Table, Table[Value Type] ="002"))

 

using isinscope, you can show that in grand total

 

if(not(isinscope(Table[Value Type])) ,[M1], sum(Table[Value]))

Thank you for your response @amitchandak 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.