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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mclawler
Helper III
Helper III

Totals Row not summing properly

Hi Everybody, I can't seem to figure out how to get the Totals row to Sum properly.  I would assume SUMX needs to be interjected in here somewhere but can't quite seem to fogure it out.  Please advise.  

 

Current Measure being used:

 

OB COUNT(Copy) =
VAR AutoCount=CALCULATE(SUM('OutstandingBalancesMaster'[Count])) + CALCULATE(COUNT('PwBi CIPL'[Balance]),OutstandingBalancesMaster[Type Description Column] = "Auto")
VAR OtherCount=COALESCE(
CALCULATE(SUM(OutstandingBalancesMaster[Count]),ALLEXCEPT('OutstandingBalancesMaster',OutstandingBalancesMaster[Type Description Column])),0)
VAR C=CALCULATE(SUM('OutstandingBalancesMaster'[Count]),FILTER('OutstandingBalancesMaster',OutstandingBalancesMaster[Type Description Column] = "Auto"))
RETURN
IF(
    ISINSCOPE(OutstandingBalancesMaster[Type Description Column]),
    SWITCH(
        TRUE(),
        MAX(OutstandingBalancesMaster[Type Description Column]) = "Auto",
        AutoCount,
        OtherCount),
        AutoCount+OtherCount-C) + 0

The individual row results are correct, just the Total is incorrect. 
 
mclawler_0-1724959704816.png

 

# Total should be 23,917 
$ Total should be $514,771,284
 
It appears to be doubling all rows sums except for Auto

 

1 ACCEPTED SOLUTION
MattAllington
Community Champion
Community Champion

The simplest way to solve the "totals don't add up" problem is to replicate the structure of the rows in your visual inside the measure. 

the reason you are getting the right answer in the row section is because each row is being calculated separately. At the total row, all of the data is aggregated and a single calculation is completed. You need to replicate the row by row calculation in the total. 

 

write a new measure that references the current measure

SUMX(VALUES(Table[Column in your visual]),[reference current measure that doesn't work])

 

or rewrite the current measure 

SUMX(VALUES(Table[Column in your visual]),CALCULATE(<all code in the current measure that doesn't work>)

 


https://exceleratorbi.com.au/use-sum-vs-sumx/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

2 REPLIES 2
MattAllington
Community Champion
Community Champion

The simplest way to solve the "totals don't add up" problem is to replicate the structure of the rows in your visual inside the measure. 

the reason you are getting the right answer in the row section is because each row is being calculated separately. At the total row, all of the data is aggregated and a single calculation is completed. You need to replicate the row by row calculation in the total. 

 

write a new measure that references the current measure

SUMX(VALUES(Table[Column in your visual]),[reference current measure that doesn't work])

 

or rewrite the current measure 

SUMX(VALUES(Table[Column in your visual]),CALCULATE(<all code in the current measure that doesn't work>)

 


https://exceleratorbi.com.au/use-sum-vs-sumx/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

That worked!! Also so easy in hindsight 🙂  

 

I wrote a new measure that referenced the old.  I tried the rewriting method and couldn't get it to foot correctly.  Thank you!!! 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.