Forum Discussion

imnotabot01001's avatar
imnotabot01001
Regular Visitor
4 years ago
Solved

Filter rows by CONTAIN criteria from a list (AND)

Hi- my table needs to be filtered by a list. Text contained in list should be used as an AND criteria (only show rows that contain all texts from list). Help please 😞   my table: Date Product...
  • PhilipTreacy's avatar
    4 years ago

    Hi imnotabot01001 

    Download sample Excel file with query

    Here's the code:

     

    let
        Source = Excel.CurrentWorkbook(){[Name="TextTable"]}[Content],
        Result = Table.AddColumn(Source, "Check", 
        
            (FindStrings) => 
            
            List.AllTrue(List.Transform(WordList, each Text.Contains((FindStrings[Product_Name]), _ )))),
        #"Filtered Rows" = Table.SelectRows(Result, each ([Check] = true)),
        #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Check"})
    
    in
        #"Removed Columns"

     

     

     

    If you want to do further reading/see more examples of this kind of thing check here

    Searching for Text Strings in Power Query • My Online Training Hub

    regards

    Phil