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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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") )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.