Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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]
Solved! Go to Solution.
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]
)
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]
)
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]
)
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]
)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
64 | |
63 | |
52 | |
36 | |
36 |
User | Count |
---|---|
81 | |
71 | |
58 | |
45 | |
44 |