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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Carrhill
Helper I
Helper I

How to look at two columns with CONTAINS STRING

Hello, 

 

I need to add two conditions to a CONTAINS STRING statement but it's not working.  I'd appreciate if somebody can help please

 

It would look something like this 

 

Column = IF( CONTAINSSTRING(('Table '[Column] "A" && CONTAINSSTRING ('Table'[Column] "B") "Y", "Z" ))
 
Thank you!!
1 ACCEPTED SOLUTION

Hi @Carrhill ,

 

Try this instead:

Output = 
VAR _FindString01 = SEARCH("ABC", [Column1], 1, 0)
VAR _FindString02 = SEARCH("XYZ", [Column2], 1, 0)

RETURN IF(_FindString01 > 0 && _FindString02 > 0, "X", "Y")

 

Example Output:

hnguy71_0-1651095551727.png

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Carrhill , Try like

 

Column = IF( CONTAINSSTRING('Table '[Column] "A") || CONTAINSSTRING ('Table'[Column] "B") || CONTAINSSTRING ('Table'[Column] "Y")|| CONTAINSSTRING ('Table'[Column] "Z") )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hey @amitchandak ,

 

Thank you!  You have solved the problem posed.   However I wasn't entirely clear in my question.

This is my goal...

If the column 1 contains "abc", and Column 2 contains "xyz", return X, else Y 

 

Is there a way to do this ?  Thanks for your help!

Hi @Carrhill ,

 

Try this instead:

Output = 
VAR _FindString01 = SEARCH("ABC", [Column1], 1, 0)
VAR _FindString02 = SEARCH("XYZ", [Column2], 1, 0)

RETURN IF(_FindString01 > 0 && _FindString02 > 0, "X", "Y")

 

Example Output:

hnguy71_0-1651095551727.png

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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