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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Function SWITCH TRUE doesn't work

Hi! 

I need some help.

 

I use the SWITCH function but with the same number, i don't have the same result and i don't known why. 

 

SWITCH(
TRUE(),
M <= 100 , "1",
M <=500, "2",
M <=1000, "3",
M <=1500, "4",
M> 1500,"5"
)
I try with IF too but i got the same result : 
IF(
M <= 100 , "1",,
IF(
M <=500, "2",
IF(
M <=1000, "3",
IF(
M <=1500, "4",
IF(
M> 1500,"5"
)
)
)
)
)
 
For the first line M = 1170,58 but the result is 4 and the second line M = 1170,40 but the result is 3. 
 
I really don't understand why it doesn't work. 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks, I found why it doesn't work. 

It's because M was a measure and the M Score was a colomn. When i changed M Score in colomn. It's worked perfectly. 

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous ,Both seems fine, If you are using a measure this should work fine as measure and if you using a column (M) this work fine as new column

 

SWITCH(
TRUE(),
[M] <= 100 , "1",
[M] <=500, "2",
[M] <=1000, "3",
[M] <=1500, "4",
[M] > 1500,"5"
)

 


Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

Thanks, I found why it doesn't work. 

It's because M was a measure and the M Score was a colomn. When i changed M Score in colomn. It's worked perfectly. 

Anonymous
Not applicable

i can't share the data but i can show you some result. 

 

idMScore
11175,023
21174,44
31159,963
41159,94
539,61
6257,32
7520,12
8178,951

 

For calculate M , i use this : 

SUM('Commandes'[CA Marchandise TTC]),
 

But the switch function doesn't work correctly. 

@Anonymous , can check the data type or M, it should be number - Decimal ?

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

the column M is General Number

the column CA Marchandise TTC is devise

and the column Score is Standard

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.