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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
aoliver
Helper III
Helper III

Select Rows if text Contains (Value of a list)

Hello everyone, ill explain my problem with examples:

 

I have a table like this:

ID - Message

1 - @asdf
2 - @8rr

3 - 674

4 - 1231@3
etc
In a List, i have the differents  values which I want to filter  of the  previous table, i.e:
List: 
@8
@3

 

What I want is filter the first table, in the case  that  the message contain  ANY of the values of the list, so my expected result would be:

1 - @asdf

3 - 674

 

Check  that its CONTAINS and not EQUAL.

Ok, lets go to M code, after my test, I could solve partially the problem, I achieve to filter if the message is Exactly the string in the List, with the following code: 

 

= Table.SelectRows(#"Replaced Value1", each not (List.Contains(List, [message])))

 

After a research, Ill try this code, but it does not work: 
= Table.SelectRows(#"Replaced Value1", each not (List.MatchesAny(List, each Text.Contains([message],_))))

 

It brings me the following error:

Expression.Error: We cannot apply field access to the type Text.

 

 

So, any ideas of how to achieve this?

 

Thanks in advance

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@aoliver here is how you can do it

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTQVXBILE5JU4rViVYyAvEsiorAHGMgx8zcBMw2AbINjYwNHYyVYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", (x) => List.MatchesAny(SearchList, each Text.Contains(x[Column1], _)))
in
    #"Added Custom"

 

here is the query for SearchList

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcrBQitUBUsZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    Column1 = #"Changed Type"[Column1]
in
    Column1

 

Would appreciate Kudos 🙂 if my solution helped.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@aoliver here is how you can do it

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTQVXBILE5JU4rViVYyAvEsiorAHGMgx8zcBMw2AbINjYwNHYyVYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", (x) => List.MatchesAny(SearchList, each Text.Contains(x[Column1], _)))
in
    #"Added Custom"

 

here is the query for SearchList

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcrBQitUBUsZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    Column1 = #"Changed Type"[Column1]
in
    Column1

 

Would appreciate Kudos 🙂 if my solution helped.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

Sorry for mention you again, my  problem has changed a little:

It is possible to filter 2 times in 2 different columns? Let me explain with an example:
My table
ID - STATUS 1 - STATUS 2
1 - TD - #8

2 - TD - #5

3 - TM - #5

I want to filter with AND not with Any, for example (in my  list) 

List 1      List2

TD          #8

TM          #5

So, List1 filters status1 and List 2 filters status2,

 

so the result would be
2 - TD - #5

 

There is a problem: the value of the list is not the whole value of status columns, its just a part of it.

 

Have the example sense? Any ideas? 
Ive tried to create 2 conditional columns but that is a OR not an AND, in logical forms.

Thanks again

 

Amazing, this is exactly what I looking for, THANKS!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.