Forum Discussion
rush
3 years agoHelper 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 typ...
- 3 years ago
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] ) - 3 years ago
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
3 years agoSuper User
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]
)
rush
3 years agoHelper V
jdbuchanan71 , thank you very much. It works well. 🙏