Forum Discussion

judithcreek's avatar
judithcreek
New Member
4 years ago
Solved

Check if column contains any value from another table's column

I have a table with a single column that contains text:   In a query, I want to check if a column has at least one of the System Statuses above:   Ultimately, I will add a column to t...
  • AlexisOlson's avatar
    4 years ago

    In this particular case, I'd recommend splitting the text into a list and using List.ContainsAny.

     

    Try putting this into the Custom Column box:

     

    List.ContainsAny(
        Text.Split([WBS Status], " "),
        SingleColumn[System Status]
    )

     

     

    Full sample query you can paste into the Advanced Editor to check out yourself:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcvYJdlEIcg12VAhy9HdWitWJVgpy9VFwdA4IUfD084QLOPmEOMMFgJoU/PydIKJwJSGuzv5gjUqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"WBS Status" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"WBS Status", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Check", each List.ContainsAny(Text.Split([WBS Status], " "), SingleColumn[System Status]), type logical)
    in
        #"Added Custom"