Forum Discussion

TM_Visual's avatar
TM_Visual
Icon for Advocate III rankAdvocate III
8 years ago
Solved

Search text in column for values from a second table

  I have a table with columns with text comments. My ideal goal would be to be able to bring up any comments that contained words flagged in a different table.   Image of an example table is below...
  • ImkeF's avatar
    8 years ago

    Hi TM_Visual, cannot tell if this is still state of the art, but this is the code to make it work for your use case:

     

    let
        Table1 = Table.Buffer(Data Table),
        Table2 = Table.Buffer(Reference Table),
        RelativeMerge = Table.AddColumn(Table1, "RelativeJoin", 
                (Earlier) => Table.SelectRows(Table2, 
                             each Text.Contains(Earlier[Comment],[Keyword], Comparer.OrdinalIgnoreCase))),
        AddContent = Table.AddColumn(RelativeMerge, "Content", each if List.Contains([RelativeJoin][TypeOfComment], "content") then true else false),
        AddStaff = Table.AddColumn(AddContent, "Staff", each if List.Contains([RelativeJoin][TypeOfComment], "staff") then true else false),
        Cleanup = Table.RemoveColumns(AddStaff,{"RelativeJoin"})
    in
        Cleanup