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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hitesh1607
Advocate II
Advocate II

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
Super User
Super User

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.