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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Difference between two groups in ROW Sub Totals Matrix Table

Hello, 

I want to put in the difference between two groups in the total header rather than a sum of groups in Row Subtotals 

For example: 
Below I want to take the difference between Sum(income) & Sum(expenditure) ie( Income- Expenditure ) in the Row subtotal header

Thank you very much in advance, 

BS097_0-1657203128016.png

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

please try

=
VAR Value = [Measure]
VAR IncomeValue =
    CALCULATE ( [Measure], TableName[IEO] = "Income" )
VAR ExpenditureValue =
    CALCULATE ( [Measure], TableName[IEO] = "Expenditure" )
RETURN
    IF ( HASONEVALUE ( TableName[IEO] ), Value, IncomeValue - ExpenditureValue )

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

please try

=
VAR Value = [Measure]
VAR IncomeValue =
    CALCULATE ( [Measure], TableName[IEO] = "Income" )
VAR ExpenditureValue =
    CALCULATE ( [Measure], TableName[IEO] = "Expenditure" )
RETURN
    IF ( HASONEVALUE ( TableName[IEO] ), Value, IncomeValue - ExpenditureValue )
Greg_Deckler
Community Champion
Community Champion

@Anonymous This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Also, MM3TR&R might help as well. Matrix Measure Total Triple Threat Rock & Roll - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello,
thank you for picking up my question.

Im beginner to power bi, Could you please help me understand solve this particular problem,
I havent used the measure to calculate the column rather i used calculated column

My issue is, i would like to take difference between two groups rather than sum, avg, or stats calculations that is readily available.

to do so, if i have to write DAX, Could you please explain me where to write DAX & on which specification of matrix does it goes 
Thank you

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors