Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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:
Solved! Go to Solution.
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
)
```
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
)
```
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.