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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

CONTAINSTRING function help

Hi All, 

I am using the containstring function to search a column to see if any cell results has "ABC" in..  

I also want to check, in the same measure if the same column containstring "EFG"..  

I have tried the || (or) inbetween the "ABC" || "EFG"  but this does not work. 

Looking forward to some help.

Regards
Rob

2 ACCEPTED SOLUTIONS
JarroVGIT
Resident Rockstar
Resident Rockstar

CONTAINSSTRING returns a Boolean (e.g. True or False). If you want to use it in a IF statement, you can use :

Check = IF(CONTAINSSTRING("ABC") || CONTAINSSTRING("EGF"), TRUE, FALSE)

Note the double 's' in containSString by the way 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Hi @Anonymous 

 

Sorry, my initial post wan't completely clear.

 

You can use either option as the logical test inside your IF statement and they would yeild the same result.

 

It's worth noting that the OR function only accepts 2 arguments so if you have more than 2, you would need to use nested OR functions.

As a result, I tend to opt for the 'or' operator '||' as I find it easier to read.

 

What I was trying to get across in my previous post is that each argument has to be a valid logical test in its own right.

So, you can't use:

Column =
IF (
    CONTAINSSTRING ( Table1[Column1], "ABC" || "EFG" ),
    "Yes",
    "No
) 

 

But instead have to use:

Column =
IF (
    CONTAINSSTRING ( Table1[Column1], "ABC" ) || CONTAINSSTRING ( Table1[Column1], "EFG" ),
    "Yes",
    "No
) 

 

Hope it helps.

 

Best regards,

Martyn

 

If I answered your question, please help others by accepting it as a solution.

 

View solution in original post

5 REPLIES 5
MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

You need to write the table and column reference for both conditions:

 

E.g.

--Using 'or' operator
CONTAINSSTRING ( Table1[Column1], "ABC" ) || CONTAINSSTRING ( Table1[Column1], "EFG" )

-- Using OR function
OR ( CONTAINSSTRING ( Table1[Column1], "ABC" ), CONTAINSSTRING ( Table1[Column1], "EFG" ) )

 

Best regards,

Martyn

 

If I answered your question, please help others by accepting it as a solution.

 

Anonymous
Not applicable

Thanks both,

Martyn, I guess you’re showing two different options, both result the same?

Thanks again

Hi @Anonymous 

 

Sorry, my initial post wan't completely clear.

 

You can use either option as the logical test inside your IF statement and they would yeild the same result.

 

It's worth noting that the OR function only accepts 2 arguments so if you have more than 2, you would need to use nested OR functions.

As a result, I tend to opt for the 'or' operator '||' as I find it easier to read.

 

What I was trying to get across in my previous post is that each argument has to be a valid logical test in its own right.

So, you can't use:

Column =
IF (
    CONTAINSSTRING ( Table1[Column1], "ABC" || "EFG" ),
    "Yes",
    "No
) 

 

But instead have to use:

Column =
IF (
    CONTAINSSTRING ( Table1[Column1], "ABC" ) || CONTAINSSTRING ( Table1[Column1], "EFG" ),
    "Yes",
    "No
) 

 

Hope it helps.

 

Best regards,

Martyn

 

If I answered your question, please help others by accepting it as a solution.

 

Anonymous
Not applicable

Hi Martyn,

Great explanation, thanks.

What I was trying to do is exactly what you’re saying not to.

“ABC” || “EFG”

Learning every day with DAX. More I learn, easier it’s getting.

Thanks
JarroVGIT
Resident Rockstar
Resident Rockstar

CONTAINSSTRING returns a Boolean (e.g. True or False). If you want to use it in a IF statement, you can use :

Check = IF(CONTAINSSTRING("ABC") || CONTAINSSTRING("EGF"), TRUE, FALSE)

Note the double 's' in containSString by the way 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.