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
Anonymous
Not applicable

Switch and If Measure - Tricky Question

Hi Experts 

 

See the two measure below. When I use the switch measure it give me only the customer that have values based on channel selection from slicer works but formatting issues..on number 

 

The if measure formats the values correctly negatives with brackets and % signs for % values and so on...

When i use the If measure it show all the customer even those with no data based on channel selection...and is not dynamic 

 

I want to use the switch measure but with the formatting as shown on the IF measure..

Fist Measure Using IF
Slicer_CM_PF1 =
VAR Mth1 =
SELECTEDVALUE ( SelMth_Current[Month] )
VAR yr =
SELECTEDVALUE ( Year_Grp[Year] )
VAR Fcst1 =
SELECTEDVALUE ( SelMth_4[Actual] )
VAR Chn =
SELECTEDVALUE ( Channel_PL[Channel])
VAR Opt = 0
VAR MthVal =
CALCULATE (
SUM ( Customers_Profitability_Consolidation[Profit] ),
Customers_Profitability_Consolidation[Period] = Fcst1,
Customers_Profitability_Consolidation[Year] = yr,
Customers_Profitability_Consolidation[Channel] = Chn,
Customers_Profitability_Consolidation[Month] = Mth1
)
VAR MTDValue =
IF(
AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=
1, FORMAT(MthVal, "#,##0.0;(#,##0.0%);-" ), IF(AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=
2, FORMAT(MthVal, "#,##0.0;(#,##0.0);-" ),
FORMAT(MthVal, "#,##0.0;(#,##0.0);-" )
))
RETURN
MTDValue
 
Second Measure
Using Switch
Slicer_CM_PF1 =
VAR Mth1 =
SELECTEDVALUE ( SelMth_Current[Month] )
VAR yr =
SELECTEDVALUE ( Year_Grp[Year] )
VAR Fcst1 =
SELECTEDVALUE ( SelMth_4[Actual] )
VAR Chn =
SELECTEDVALUE ( Channel_PL[Channel])
VAR Opt = 0
VAR MthVal =
CALCULATE (
SUM ( Customers_Profitability_Consolidation[Profit] ),
Customers_Profitability_Consolidation[Period] = Fcst1,
Customers_Profitability_Consolidation[Year] = yr,
Customers_Profitability_Consolidation[Channel] = Chn,
Customers_Profitability_Consolidation[Month] = Mth1
)
VAR MTDValue =
SWITCH(
AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] ),
1, MthVal *100,
2, MthVal,
MthVal
)
RETURN
MTDValue
 
 
 
 
 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

VAR MTDValue =
IF(
AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=
1, FORMAT(MthVal, "#,##0.0;(#,##0.0%);-" ), IF(AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=
2, FORMAT(MthVal, "#,##0.0;(#,##0.0);-" ),
FORMAT(MthVal, "#,##0.0;(#,##0.0);-" )
))
 
1. you cannot mix values and percentages in the same format command.
2. the second option is not needed
 
Change your code to 
VAR MTDValue =
IF(AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=1, FORMAT(MthVal, "#,##0.0%;(#,##0.0%);-" )
,FORMAT(MthVal, "#,##0.0;(#,##0.0);-" )
)
 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

VAR MTDValue =
IF(
AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=
1, FORMAT(MthVal, "#,##0.0;(#,##0.0%);-" ), IF(AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=
2, FORMAT(MthVal, "#,##0.0;(#,##0.0);-" ),
FORMAT(MthVal, "#,##0.0;(#,##0.0);-" )
))
 
1. you cannot mix values and percentages in the same format command.
2. the second option is not needed
 
Change your code to 
VAR MTDValue =
IF(AVERAGE ( Customers_Profitability_Consolidation[Chkfmt] )=1, FORMAT(MthVal, "#,##0.0%;(#,##0.0%);-" )
,FORMAT(MthVal, "#,##0.0;(#,##0.0);-" )
)
 
Anonymous
Not applicable

Many thanks

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.