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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ZaraTyf1983
New Member

Total showing wrong

Hi everyone,
I have a DAX formula that's showing incorrect total values in the table visual. I understand the reason behind it, but I'm unsure how to fix it.

   MPY Reward Exc. GST =
 IF (
        AND ( [#MPY] > 0, [#MPY] < 150000 ),
        0,
        IF (
            AND ( [#MPY] >= 150000, [#MPY] < 400000 ),
             [#MPY] * 0.0227,
            IF (
                AND ( [#MPY] >= 400000, [#MPY] < 700000 ),
                [#MPY] * 0.0273,
                IF (
                    AND ( [#MPY] >= 700000, [#MPY] < 1000000 ),
                    [#MPY] * 0.0318,
                    IF (
                        AND ( [#MPY] >= 1000000, [#MPY] < 3000000 ),
                        [#MPY] * 0.0364,
                        [#MPY] * 0.0409
                    )
                )
            )
        )
    )
)

ZaraTyf1983_1-1733270193795.png



The expected total should be $1,186,662, but it's currently showing $1,381,418.

Thanks in advance!

1 ACCEPTED SOLUTION
SacheeTh
Resolver II
Resolver II

Can't say anything without your data, but by the look of it it seems the issue with incorrect total values in a table visual is common when using DAX calculations, especially with IF conditions like yours. This happens because DAX treats the "total" row differently than the row context, leading to undesired results.

To fix it, you can modify your measure to ensure that the total calculation is correct. You can use the SUMX function, which will iterate over the rows of your table to calculate the correct total, taking the row-level logic into account.

Here’s how you can modify your measure:

MPY Reward Exc. GST =
SUMX (
    VALUES ( YourTableName[#MPY] ),
    IF (
        AND ( [#MPY] > 0, [#MPY] < 150000 ),
        0,
        IF (
            AND ( [#MPY] >= 150000, [#MPY] < 400000 ),
            [#MPY] * 0.0227,
            IF (
                AND ( [#MPY] >= 400000, [#MPY] < 700000 ),
                [#MPY] * 0.0273,
                IF (
                    AND ( [#MPY] >= 700000, [#MPY] < 1000000 ),
                    [#MPY] * 0.0318,
                    IF (
                        AND ( [#MPY] >= 1000000, [#MPY] < 3000000 ),
                        [#MPY] * 0.0364,
                        [#MPY] * 0.0409
                    )
                )
            )
        )
    )
)

Here, VALUES ( YourTableName[#MPY] ) part ensures that the calculation is performed row by row.
This approach will calculate the total as the sum of individual row results, rather than applying the measure logic to an aggregate context, which leads to incorrect results.

I know this solution doesn't fully address your problem, please provide more context 

View solution in original post

2 REPLIES 2
SacheeTh
Resolver II
Resolver II

Can't say anything without your data, but by the look of it it seems the issue with incorrect total values in a table visual is common when using DAX calculations, especially with IF conditions like yours. This happens because DAX treats the "total" row differently than the row context, leading to undesired results.

To fix it, you can modify your measure to ensure that the total calculation is correct. You can use the SUMX function, which will iterate over the rows of your table to calculate the correct total, taking the row-level logic into account.

Here’s how you can modify your measure:

MPY Reward Exc. GST =
SUMX (
    VALUES ( YourTableName[#MPY] ),
    IF (
        AND ( [#MPY] > 0, [#MPY] < 150000 ),
        0,
        IF (
            AND ( [#MPY] >= 150000, [#MPY] < 400000 ),
            [#MPY] * 0.0227,
            IF (
                AND ( [#MPY] >= 400000, [#MPY] < 700000 ),
                [#MPY] * 0.0273,
                IF (
                    AND ( [#MPY] >= 700000, [#MPY] < 1000000 ),
                    [#MPY] * 0.0318,
                    IF (
                        AND ( [#MPY] >= 1000000, [#MPY] < 3000000 ),
                        [#MPY] * 0.0364,
                        [#MPY] * 0.0409
                    )
                )
            )
        )
    )
)

Here, VALUES ( YourTableName[#MPY] ) part ensures that the calculation is performed row by row.
This approach will calculate the total as the sum of individual row results, rather than applying the measure logic to an aggregate context, which leads to incorrect results.

I know this solution doesn't fully address your problem, please provide more context 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.