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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AgnihotramKris
New Member

Totals not working when measure with IF

Hi All,

 

I have a measure with IF as like below.

MTD = IF([ABC]="XYZ", measure1, measure2)

When I use MTD in the matrix all values are showing correctly. But when I add row totals immediately giving error, saying multiple values provided when sigle value is expected.

If I change my measure as MTD = measure2 then totals are coming perfectly fine, but I want to use above if condition or switch to get my desired result.

 

Not sure what is the problem. Can someone please guide me how to go ahead.

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AgnihotramKris ,

 

IF() function will calculate result based on [ABC], subtotal in matrix does not has a value in [ABC], so you won't get total in martix subtotal.

Here I suggest you to create a new measure based on this one by SUMX().

MTD = IF([ABC]="XYZ", measure1, measure2)

New Measure:

SUMX = SUMX('TABLE',[MTD])

 

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

4 REPLIES 4
AgnihotramKris
New Member

I got the answer.. actually I used MTD = IF(VALUES(ABC) ="XYZ", measure 1, measure 2).

I am supposed to used IF(SELECTEDVALUE(ABC)="XYZ", measure 1, measure 2)

Anonymous
Not applicable

Hi @AgnihotramKris ,

 

IF() function will calculate result based on [ABC], subtotal in matrix does not has a value in [ABC], so you won't get total in martix subtotal.

Here I suggest you to create a new measure based on this one by SUMX().

MTD = IF([ABC]="XYZ", measure1, measure2)

New Measure:

SUMX = SUMX('TABLE',[MTD])

 

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.

latimeria
Solution Specialist
Solution Specialist

Hi,

 

It is not clear what you try to achieve.

My understanding is that you want a measure for details and another one for totals.

In this case, have a look at isinscope - https://dax.guide/isinscope/ 

MTD = if( isinscope [detail row column], , measure1, measure2)

amitchandak
Super User
Super User

@AgnihotramKris , In a measure you can use measure or aggregated values

 

MTD = IF(Max(Table[ABC]) ="XYZ", measure1, measure2)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.