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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Power BI DAX Function 'SWITCH' does not support comparing values of type True/False

I am getting this error when I try to create a column in Power BI:


Function 'SWITCH' does not support comparing values of type True/False with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.


How do I fix this?


Here is the DAX for the column I am creating:

 

02_00 001 SSY SKY and BOTH =
SWITCH(
TRUE(),
SEARCH("Yes",'looker_tables lkr_Questionnaire'[02_Animals_Processed__003_Have_animals_been_supplied_for_Service_Kill_*846fa9d1-9ac6-4663-b4fc-4298487c7406],"Service Kill",0),
SEARCH("Yes",'looker_tables lkr_Questionnaire'[02_Animals_Processed__004_Have_animals_been_processed_for_Supplementary_supply_*bd69ebd2-f869-4593-b75d-e9bf0f4a8e4f],"Supplementary Supply",0),
SEARCH("1",'looker_tables lkr_Questionnaire'[02_00 002 SSY SKY],"Both",0)
)
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , I think the formula is not used correctly

 

It should be like

SWITCH(
TRUE(),
SEARCH("Yes",'looker_tables lkr_Questionnaire'[02_Animals_Processed__003_Have_animals_been_supplied_for_Service_Kill_*846fa9d1-9ac6-4663-b4fc-4298487c7406],,0) >0,"Service Kill",
SEARCH("Yes",'looker_tables lkr_Questionnaire'[02_Animals_Processed__004_Have_animals_been_processed_for_Supplementary_supply_*bd69ebd2-f869-4593-b75d-e9bf0f4a8e4f],,0)>0,"Supplementary Supply"
SEARCH("1",'looker_tables lkr_Questionnaire'[02_00 002 SSY SKY],,0) >0,"Both"
)

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , I think the formula is not used correctly

 

It should be like

SWITCH(
TRUE(),
SEARCH("Yes",'looker_tables lkr_Questionnaire'[02_Animals_Processed__003_Have_animals_been_supplied_for_Service_Kill_*846fa9d1-9ac6-4663-b4fc-4298487c7406],,0) >0,"Service Kill",
SEARCH("Yes",'looker_tables lkr_Questionnaire'[02_Animals_Processed__004_Have_animals_been_processed_for_Supplementary_supply_*bd69ebd2-f869-4593-b75d-e9bf0f4a8e4f],,0)>0,"Supplementary Supply"
SEARCH("1",'looker_tables lkr_Questionnaire'[02_00 002 SSY SKY],,0) >0,"Both"
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.