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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
braineems
Regular Visitor

Switch does not support comparing values of type true/false

I want to add a new measure Batting Order but when I add it to my table chart it says function 'SWITCH' does not support coparing values of type True/False with values of type Text. consider using the VALUE or FORMAT function to convert one of the values.

 

Below is my formula:

 

Batting Order = SWITCH (
    TRUE,
"Jos Buttler",1,
"Rilee Rossouw",2,
"Alex Hales",2,
"Virat Kohli",3,
"Suryakumar Yadav" ,4,
"Glenn Phillips" ,5,
"Marcus Stoinis" ,6,
"Glenn Maxwell" ,6,
"Hardik Pandya" ,6,
"Sikandar Raza" ,7,
"Rashid Khan" ,8,
"Shadab Khan" ,8,
"Sam Curran" ,9,
"Shaheen Shah Afridi" ,10,
"Anrich Nortje" ,11  
)
 
braineems_0-1691263600093.png

 

1 ACCEPTED SOLUTION
AmiraBedh
Super User
Super User

It looks like you're trying to define a new measure using the DAX formula language, specifically using the `SWITCH` function to map names to batting orders.

The issue with the code you've posted is that you're using `TRUE` as the expression for the `SWITCH` function, but then you're trying to compare it to a text value (the names of the players). The `SWITCH` function expects the first argument to be an expression that it will compare against the subsequent values in the list, so it doesn't make sense to compare a boolean `TRUE` value with text.

Since you're trying to match a player's name, you need to reference the appropriate field or variable that holds the player's name. If, for example, you have a column named `PlayerName`, you could modify your code like this:

```dax
Batting Order = SWITCH(
[Name],
"Jos Buttler", 1,
"Rilee Rossouw", 2,
"Alex Hales", 2,
"Virat Kohli", 3,
"Suryakumar Yadav", 4,
"Glenn Phillips", 5,
"Marcus Stoinis", 6,
"Glenn Maxwell", 6,
"Hardik Pandya", 6,
"Sikandar Raza", 7,
"Rashid Khan", 8,
"Shadab Khan", 8,
"Sam Curran", 9,
"Shaheen Shah Afridi", 10,
"Anrich Nortje", 11,
BLANK() -- default case if none of the above match
)
```

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

1 REPLY 1
AmiraBedh
Super User
Super User

It looks like you're trying to define a new measure using the DAX formula language, specifically using the `SWITCH` function to map names to batting orders.

The issue with the code you've posted is that you're using `TRUE` as the expression for the `SWITCH` function, but then you're trying to compare it to a text value (the names of the players). The `SWITCH` function expects the first argument to be an expression that it will compare against the subsequent values in the list, so it doesn't make sense to compare a boolean `TRUE` value with text.

Since you're trying to match a player's name, you need to reference the appropriate field or variable that holds the player's name. If, for example, you have a column named `PlayerName`, you could modify your code like this:

```dax
Batting Order = SWITCH(
[Name],
"Jos Buttler", 1,
"Rilee Rossouw", 2,
"Alex Hales", 2,
"Virat Kohli", 3,
"Suryakumar Yadav", 4,
"Glenn Phillips", 5,
"Marcus Stoinis", 6,
"Glenn Maxwell", 6,
"Hardik Pandya", 6,
"Sikandar Raza", 7,
"Rashid Khan", 8,
"Shadab Khan", 8,
"Sam Curran", 9,
"Shaheen Shah Afridi", 10,
"Anrich Nortje", 11,
BLANK() -- default case if none of the above match
)
```

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors