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
tstraker
Frequent Visitor

Text.Contains Error "cannot convert the value [string] to type logic"

Hi,

 

I'm trying to createa  calculated column that will search [application names] and tag those can contain certain text.

 

My attempt is below:

operations tag = if(Text.Contains([Application Name], "CIP1" or "ETL" or "OPS", 1) > 0) 
then "Operations Component"
else ""

The error I recieve is as follows:

 

Expression.Error: We cannot convert the value "CIP1" to type Logical.
Details:
    Value=CIP1
    Type=Type

 

I understand the issue here is that I'm mixing boolean logic with a string but whats the best way to go about it?

 

I realise I could probably use a conditional column instead but I may have ALOT of values to search the database for so it makes sense for me to have it in a function as opposed to a "click click click click" process.


Should I be using another method or have I written the Text.Contains incorrectly?

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Does this M language formula do the job?

=if Text.Contains([Application Name], "CIP1")=TRUE or Text.Contains([Application Name], "ETL")=TRUE or Text.Contains([Application Name], "OPS")=TRUE then "Operations Component" else null


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Does this M language formula do the job?

=if Text.Contains([Application Name], "CIP1")=TRUE or Text.Contains([Application Name], "ETL")=TRUE or Text.Contains([Application Name], "OPS")=TRUE then "Operations Component" else null


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
kentyler
Solution Sage
Solution Sage

This is from the example for text.contains

EVALUATE
	ROW(
		"Case 1", CONTAINSSTRING("abcd", "bc"), 
		"Case 2", CONTAINSSTRING("abcd", "BC"),
		"Case 3", CONTAINSSTRING("abcd", "a*d"),
		"Case 4", CONTAINSSTRING("abcd", "ef")
	)
You might use something like
 if(
OR(
OR(CONTAINSSTRING([Application Name], "CIP1"),CONTAINSSTRING([Application Name],"ETL"),
CONTAINSSTRING([Application Name], "OPS"),
"Operations Component,
"") 
 

 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


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.