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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Incorrect Total in Column Matrix view

Good afternoon,

 

I have prepared a matrix view that has Rows of Locations. Columns of Volumes, Unit Margin & Location Average Margin. In the column I have a measure that is the difference of Margin * Volume. 

 

The formula is (Unit Margin - Location Unit Margin)*Volume. Due to this measure, My column total is considering the formula and not the Column Total. As you can see below, The differnce should be the sum of the column values, but PowerBi is considering the formula above to calculate the total. 

 

Undercover95_1-1598599009869.png

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

I build two tables like yours to have a test.

Table1:

1.png

Table2:

2.png

Add two measures Volume and Unit Margin into Table1.

Unit Margin = SUM(Table2[Unit Margin])
Volume = SUM(Table2[Volume])

Then I build a measure and a calculated column to achieve your goal.

Calculated Column:

Actual Difference = 
VAR _FORMULA = ('Table1'[Unit Margin]-'Table1'[Loc Unit Margin])*'Table1'[Volume]
RETURN
_FORMULA

 Measure:

Difference in Power Bi = 
VAR _Formula =
     ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume]
RETURN
    IF (
        HASONEVALUE ( Table1[Location] ),
        _Formula,
        SUMX (
            SUMMARIZE (
                Table1,
                Table1[Location],
                "_Formula",
                     ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume]
            ),
            [_Formula]
        )
    )

Result:

3.png

You can download the pbix file from this link: Incorrect Total in Column Matrix view

 

Best Regards,

Rico Zhou

 

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

View solution in original post

5 REPLIES 5
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

Anonymous
Not applicable

Thanks @v-rzhou-msft, The excel numbers were just a sample to explain the problem I am having. I have all the numbers i have mentioned in the file as Measures in my existing table. Eg: Volume, Unit Margin, Loc Unit Margin. Only customer & Location is a column in my table.

 

I will try to get a pbix file and share it at the earliest. Thank you for the help!

amitchandak
Super User
Super User

@Anonymous , if they are from the same table it should be like

 

Sumx(Table,( [Unit Margin] - [Location Unit Margin])*[Volume])

 

for different tables please fice a row context using values or summarize with common dimension

 

refer:https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-2-Date-Difference-Across/ba-p/934397#M451

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak My Unit Margin & Volume is a measure & only Loc Unit Margin is a column. Hence the Sumx will not work in this scenario, right? Sorry, i should have mentioned that in the post.

Hi @Anonymous 

I build two tables like yours to have a test.

Table1:

1.png

Table2:

2.png

Add two measures Volume and Unit Margin into Table1.

Unit Margin = SUM(Table2[Unit Margin])
Volume = SUM(Table2[Volume])

Then I build a measure and a calculated column to achieve your goal.

Calculated Column:

Actual Difference = 
VAR _FORMULA = ('Table1'[Unit Margin]-'Table1'[Loc Unit Margin])*'Table1'[Volume]
RETURN
_FORMULA

 Measure:

Difference in Power Bi = 
VAR _Formula =
     ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume]
RETURN
    IF (
        HASONEVALUE ( Table1[Location] ),
        _Formula,
        SUMX (
            SUMMARIZE (
                Table1,
                Table1[Location],
                "_Formula",
                     ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume]
            ),
            [_Formula]
        )
    )

Result:

3.png

You can download the pbix file from this link: Incorrect Total in Column Matrix view

 

Best Regards,

Rico Zhou

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.