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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
rush
Helper V
Helper V

SEARCH and SWITCH Data type issues

Hi 

 

I need help trying to search for a text in a column and bring back a value due to the error below:

Function 'SWITCH' does not support comparing values of type True/False with values of type Text.

Your help is much appreciated.

Client =
SWITCH( TRUE(),
SEARCH("Apple", 'Billing and GP'[Project Name], 1 , 0) = 1  , "Apple", 'Billing and GP'[Client Name] ,
SEARCH("Pear", 'Billing and GP'[Project Name], 1 , 0) = 1, "Pear", 'Billing and GP'[Client Name],
'Billing and GP'[Client Name] 

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

@rush 

Try it withouth the second text string.  You just need the TRUE part on each line of the SWITCH

 

Client = 
SWITCH( TRUE(),
SEARCH("Apple", 'Billing and GP'[Project Name], 1 , 0) = 1 , "Apple",
SEARCH("Pear", 'Billing and GP'[Project Name], 1 , 0) = 1, "Pear",
'Billing and GP'[Client Name] 
)

 

View solution in original post

@rush 

I think you would be better off using CONTAINSSTRING.  That way it will looking the whole string, not just the start and you can simplify it a bit:

Client = 
SWITCH( TRUE(),
    CONTAINSSTRING('Billing and GP'[Project Name],"Apple"),"Apple",
    CONTAINSSTRING('Billing and GP'[Project Name],"Pear"),"Pear",
    'Billing and GP'[Client Name]
)

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

@rush 

Try it withouth the second text string.  You just need the TRUE part on each line of the SWITCH

 

Client = 
SWITCH( TRUE(),
SEARCH("Apple", 'Billing and GP'[Project Name], 1 , 0) = 1 , "Apple",
SEARCH("Pear", 'Billing and GP'[Project Name], 1 , 0) = 1, "Pear",
'Billing and GP'[Client Name] 
)

 

@jdbuchanan71 , thank you very much. It works well. 🙏

 

@rush 

I think you would be better off using CONTAINSSTRING.  That way it will looking the whole string, not just the start and you can simplify it a bit:

Client = 
SWITCH( TRUE(),
    CONTAINSSTRING('Billing and GP'[Project Name],"Apple"),"Apple",
    CONTAINSSTRING('Billing and GP'[Project Name],"Pear"),"Pear",
    'Billing and GP'[Client Name]
)

@jdbuchanan71 Thank you. This is better. Much appreciated. 🙏

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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