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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
pelowski
Helper III
Helper III

Filter each list within a column for lines that contain strings

I'm trying to parse out parts of an email message containing certain search terms.  I've got it to the point where I've filtered to only those messages that contains the strings I want and have it such that each new line of the email message is in a list in one of the columns.  Now, in order to make it more clear in my report about what was found (and the context in which it was found), I'm trying to filter out those lines that do not contain the string that I wanted to find.  But I'm having problems filtering the lists in my "Split on Values" columns to only include the (case insensitive) strings I'm trying to find.  Ultimately, I want to combine it back into a string column leaving only those lines that contained the string I was trying to return in first place.

(I've tried List.Contains but that only uses exact matches, and can't seem to figure out how to use Text.Contains within a List within a column like this.)

 

PQ - Filter only List Elements that contain case-insensitive string.png

 

Any help you can provide would be greatly apprecated!

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @pelowski 

 

you can surround your custom function like this

let
	Source = #table 
	(
		{"Facility"},
		{ {"This is a test"}, {"this is fantastic"}, {"Test123"}, {"13:00 am"} } 
	),
	Facility = List.Select
	(
		Source[Facility], //your custom function goes here
	(
		listitem
	)=>
	List.AnyTrue
	(
		List.Transform
		(
			{"test","1"}, //words to be searched go here
			(
				transfrom
			)=>
			Text.Contains
			(
				listitem,
				transfrom,
				Comparer.OrdinalIgnoreCase
			)
		)
)
)
 in 
	Facility

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

View solution in original post

3 REPLIES 3
Jimmy801
Community Champion
Community Champion

Hello @pelowski 

 

you can surround your custom function like this

let
	Source = #table 
	(
		{"Facility"},
		{ {"This is a test"}, {"this is fantastic"}, {"Test123"}, {"13:00 am"} } 
	),
	Facility = List.Select
	(
		Source[Facility], //your custom function goes here
	(
		listitem
	)=>
	List.AnyTrue
	(
		List.Transform
		(
			{"test","1"}, //words to be searched go here
			(
				transfrom
			)=>
			Text.Contains
			(
				listitem,
				transfrom,
				Comparer.OrdinalIgnoreCase
			)
		)
)
)
 in 
	Facility

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

@Jimmy801, thank you!  I got it working with each list within the column.  I'll spend some time this afternoon trying to better understand what it's doing.

Hello @pelowski 

 

perfect.

Enjoy the findings.

In case you have question, just ask me

 

Bye

 

Jimmy

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors
Top Kudoed Authors