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

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

Reply
jalaomar
Helper IV
Helper IV

Getting sum correct in a Matrix table

Hello, 

 

I am facing an issue with a report where I visualize financial data in a matrix table, just to provide a simple example I have 3 measure 

1. 

Total Actual cost = CALCULATE(
SUM('Data Rel'[Actual Cost]), REMOVEFILTERS('Data Rel'[Division]))
 
2. 
Total Forecast cost = CALCULATE( SUM('Data Rel'[Forecast Cost]), REMOVEFILTERS('Data Rel'[Division]))
 
3. 
POC % = CALCULATE( DIVIDE('Data Rel'[Total Actual cost],'Data Rel'[Total Forecast cost]), REMOVEFILTERS('Data Rel'[Division]))
 
Note that in my data, there is column regarding the Division for a Projects 
 
The following table is the expected outcome:
 
Project IDDivision Actual cost Forecast CostPOC%
ABeverage10005000 
ABeverage20001000 
ACommon10001000 
ABeverage40005000 
Total 80001200067%

 

But in my Matrix table, when I add the Category I get the following results, which is incorrect. since sum of Actual cost 7000 and is excluding the row where the Category is equal to "Common".

 

Project IDDivision Actual cost Forecast CostPOC%
ABeverage10005000 
ABeverage20001000 
ACommon10001000 
ABeverage40005000 
Total 70001100064%

 

Anyone know how to manage this issue as I have no control of the data input.

 

BR

J

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jalaomar ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

1. Update the formula of measure [Total Actual cost] and [Total Forecast cost]

Total Actual cost = 
IF (
    SELECTEDVALUE ( 'Data Rel'[Division] ) = "Beverage",
    CALCULATE (
        SUM ( 'Data Rel'[Actual Cost] ),
        ALLSELECTED ( 'Data Rel'[Division] )
    ),
    BLANK ()
)
Total Forecast cost = 
IF (
    SELECTEDVALUE ( 'Data Rel'[Division] ) = "Beverage",
    CALCULATE (
        SUM ( 'Data Rel'[Forecast Cost] ),
        ALLSELECTED ( 'Data Rel'[Division] )
    ),
    BLANK ()
)

2. Create two measures as below to get the correct total sum of actual cost and forecast cost

Actual = 
IF (
    ISINSCOPE ( 'Data Rel'[Division] ),
    [Total Actual cost],
    SUMX (
        GROUPBY ( 'Data Rel', 'Data Rel'[Project ID], 'Data Rel'[Division] ),
        [Total Actual cost]
    )
)
Forecast = 
IF (
    ISINSCOPE ( 'Data Rel'[Division] ),
    [Total Forecast cost],
    SUMX (
        GROUPBY ( 'Data Rel', 'Data Rel'[Project ID], 'Data Rel'[Division] ),
        [Total Forecast cost]
    )
)

3. Update the formula of measure [POC %] as below

POC % = DIVIDE([Actual],[Forecast])

yingyinr_1-1652173890887.png

In addition, you can refer the method in the following links to handle with incorrect total values on the matrix visual...

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@jalaomar , Not very clear. if you need grand total then try like

 

1.
Total Actual cost = CALCULATE(
SUM('Data Rel'[Actual Cost]), allselected())

2.
Total Forecast cost = CALCULATE( SUM('Data Rel'[Forecast Cost]), allselected())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

 

Just tried it and it didn't provide the Grand total 😞

 

 

@jalaomar 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



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...

Hi,

 

tried out the suggested measures but that didn't work eaither 😞

 

jalaomar_0-1651773619253.png

jalaomar_1-1651773638047.png

 

Below is an example of what happens when I add the Division column in the Matrix Table 

The totals looks OK, but I only want to show one row of the Division (Beverage), together with total values 

jalaomar_2-1651773728881.png

 

So then I filter on the Net Sales price greater than 0

It Provides me the summary of the Division but then lose some of totals for Actual Cost, as you can see the second row level with some actual cost dissapears.

 

jalaomar_3-1651773810865.png

 

any clue on how I can manage this correctly?

 

Anonymous
Not applicable

Hi @jalaomar ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want. 

1. Update the formula of measure [Total Actual cost] and [Total Forecast cost]

Total Actual cost = 
IF (
    SELECTEDVALUE ( 'Data Rel'[Division] ) = "Beverage",
    CALCULATE (
        SUM ( 'Data Rel'[Actual Cost] ),
        ALLSELECTED ( 'Data Rel'[Division] )
    ),
    BLANK ()
)
Total Forecast cost = 
IF (
    SELECTEDVALUE ( 'Data Rel'[Division] ) = "Beverage",
    CALCULATE (
        SUM ( 'Data Rel'[Forecast Cost] ),
        ALLSELECTED ( 'Data Rel'[Division] )
    ),
    BLANK ()
)

2. Create two measures as below to get the correct total sum of actual cost and forecast cost

Actual = 
IF (
    ISINSCOPE ( 'Data Rel'[Division] ),
    [Total Actual cost],
    SUMX (
        GROUPBY ( 'Data Rel', 'Data Rel'[Project ID], 'Data Rel'[Division] ),
        [Total Actual cost]
    )
)
Forecast = 
IF (
    ISINSCOPE ( 'Data Rel'[Division] ),
    [Total Forecast cost],
    SUMX (
        GROUPBY ( 'Data Rel', 'Data Rel'[Project ID], 'Data Rel'[Division] ),
        [Total Forecast cost]
    )
)

3. Update the formula of measure [POC %] as below

POC % = DIVIDE([Actual],[Forecast])

yingyinr_1-1652173890887.png

In addition, you can refer the method in the following links to handle with incorrect total values on the matrix visual...

Why Your Total Is Incorrect In Power BI - The Key DAX Concept To Understand

Dax for Power BI: Fixing Incorrect Measure Totals

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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.