cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hitesh1607
Helper I
Helper I

Power BI matrix Column Total is correct but row total is wrong

Hi -

I have one measure called XYZ

which is directly coming from the ABC table by measure XYZ= SUMX('ABC'[XYZ])
XYZ ( I am getting correct results for this measure) Note there are some blanks

nameJanFebMarrow Total
a10  10
b5  5
Column Total15  15

 

I have a second measure called RTY

which is directly coming from the DEF table by measure RTY = SUMX('DEF'[RTY])

This is correct too

nameJanFebMarrow Total
a10101030
b10201040
Column Total20302070

 

I am trying to calculate FINAL = If ( XYZ = 0, RTY, XYZ)

 

The final measure solution should be:

nameJanFebMarrow Total
a1010105 (i am getting this incorrect)
b5201030(i am getting this incorrect)
Column Total15302040((i am getting this incorrect)

 

3 REPLIES 3
selimovd
Community Champion
Community Champion

Hey @hitesh1607 ,

 

SUMX is an iterative function. If you just want the sum of a specific column just use the SUM function.

Try the following:

Sum XYZ = SUM( 'ABC'[XYZ] )
Sum RTY = SUM( 'DEF'[RTY] )

 

As another measure you can do your IF clause:

FINAL = IF ( [Sum XYZ] = 0, [Sum RTY], [Sum XYZ] )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

If I use the above code even then I am getting the wrong row subtotal. (Column subtotal is working fine in the matrix visual)

Hi @hitesh1607 ,

 

Please try:

XYZ_ = SUM( 'ABC'[XYZ] )

RTY_ = SUM( 'DEF'[RTY] )

FINAL = 
VAR C_ = IF([XYZ_]=0,[RTY_],[XYZ_])
RETURN 
SUMX(VALUES('GHI'[MONTH]),C_)

If the problem persists,could you share the sample pbix with dummy data?

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-... 

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

 

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors