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
Anonymous
Not applicable

How can I have an M Query Text.Contains function search for multiple possible words in a field?

I would like to have a Text.Contains that searches Column A for "Example" OR "Examples" OR "Examples2". I am sure it is staring me in the face but I cannot figure out how to do it.

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Please try this:

if Text.Contains([Column1],"Example") = true then [Column1] else null

2.PNGThe function of Text.Contains will search out all the data which contains the key word. So you just need to write Text.Contains one time.

 

If you want to filter data, you could try this:

= Table.SelectRows(#"Changed Type", each Text.Contains([Column1], "Example"))

3.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
JasonTX
Resolver I
Resolver I

If you are trying to perform this on a table, you would like to use something like:

 

#"Filtered Rows" = Table.SelectRows(table, each( Text.Contains([ColumnA], "Executive") or Text.Contains([ColumnA], "General") ))

 

 

Regards

Anonymous
Not applicable

@JasonTX, thanks for the suggestion. I have been doing it that way, but I am hoping I can cut out the repetitious "Text.Contains".

Hi @Anonymous ,

Please try this:

if Text.Contains([Column1],"Example") = true then [Column1] else null

2.PNGThe function of Text.Contains will search out all the data which contains the key word. So you just need to write Text.Contains one time.

 

If you want to filter data, you could try this:

= Table.SelectRows(#"Changed Type", each Text.Contains([Column1], "Example"))

3.PNG

Best Regards,

Xue Ding

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.