cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pbiuser2
Helper IV
Helper IV

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 @pbiuser2 ,

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

@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 @pbiuser2 ,

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.