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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
DPCCGF
Helper IV
Helper IV

Matrix Summary Row Total

Hello, I have a Matrix with Column Headers of Months and Row Headers for Account Summary, Account Group and Account.  The Summary is Gross Margin, Operating Expenses, Other Income and Other Expense.  All "positive" numbers.  How can one easily get a total that takes Gross Margin - Operating Expenses+Other Income-Other Expense so I can have a NET.  Thanks!  

2 ACCEPTED SOLUTIONS

Thank you Rita, let me check the video.  If it works great!  If not I will send out the pbix file.  Thank you for your solution on the other item as well. 

View solution in original post

Hi @DPCCGF 
You can create Dax formula like mine (Dividing by a million is only to reduce the cognitive load of dealing with too many digits; you can skip it if you'd like.)

Bud_ =
var
budget_ = sum('Balances'[Budget])
var
Gross_ = CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Gross Margin"))
VAR
Operating_ = CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Operating Expenses"))
Var
Other_ex = Operating_ = CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Other Expenses"))
VAR
Other_in=  CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Other Income"))
RETURN
if(HASONEFILTER(Balances[Account Summary]),budget_,Gross_-Operating_-Other_ex+Other_in)/1000000
 
Result :
Ritaf1983_0-1728180794407.png

The sample logic should be applied to all the measures.
The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

8 REPLIES 8
Ritaf1983
Super User
Super User

Hi @DPCCGF 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Rita, first thanks for your other solution.  Regarding sharing of the data, how do I do that?  Basically, I have the matrix below that can be drilled down on rows.  Trying to get the Total Line to perform the following:

 

Gross Margin - Operating Expenses + Other Income - Other Expense.  Right now by default it summarizes everything.

 

DPCCGF_0-1728154106180.png

 

Hi @DPCCGF 
According to sharing the file, you can save it in some public cloud and share via a link.
Regarding different logic for the total, in general, you can use functions like `ISINSCOPE` and `HASONEFILTER` to define a different calculation logic for the total row than what you have at the item level.
There is a video guide to how it works:
https://www.youtube.com/watch?v=xAZY9FyLDPo

For more specific assistance I need to see the pbix

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @DPCCGF 
You can create Dax formula like mine (Dividing by a million is only to reduce the cognitive load of dealing with too many digits; you can skip it if you'd like.)

Bud_ =
var
budget_ = sum('Balances'[Budget])
var
Gross_ = CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Gross Margin"))
VAR
Operating_ = CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Operating Expenses"))
Var
Other_ex = Operating_ = CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Other Expenses"))
VAR
Other_in=  CALCULATE(sum('Balances'[Budget]),FILTER('Balances','Balances'[Account Summary]="Other Income"))
RETURN
if(HASONEFILTER(Balances[Account Summary]),budget_,Gross_-Operating_-Other_ex+Other_in)/1000000
 
Result :
Ritaf1983_0-1728180794407.png

The sample logic should be applied to all the measures.
The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi Rita,

 

Can you help me determine why - when using your formula - getting incorrect totals when I have oddball numbers?  Thanks!

 

DPCCGF_0-1728255719890.png

 

Hi @DPCCGF 
The number in brackets is negative, the formula returns a correct result , - - = +:

Ritaf1983_1-1728266329006.png

 

If there's a need to override the accounting calculation, you can wrap the variables in the ABS function, which returns the absolute value. However, based on how it looks, it seems that an incorrect result will be produced.

https://learn.microsoft.com/en-us/dax/abs-function-dax

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thank you Rita, let me check the video.  If it works great!  If not I will send out the pbix file.  Thank you for your solution on the other item as well. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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