Forum Discussion

pelowski's avatar
pelowski
Icon for Helper III rankHelper III
6 years ago
Solved

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

 

 

Any help you can provide would be greatly apprecated!

  • 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

     

3 Replies

  • Jimmy801's avatar
    Jimmy801
    Icon for Community Champion rankCommunity 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

     

    • pelowski's avatar
      pelowski
      Icon for Helper III rankHelper III

      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.

      • Jimmy801's avatar
        Jimmy801
        Icon for Community Champion rankCommunity Champion

        Hello pelowski 

         

        perfect.

        Enjoy the findings.

        In case you have question, just ask me

         

        Bye

         

        Jimmy