Forum Discussion

jonclay's avatar
jonclay
Helper IV
1 year ago
Solved

Problem with List.Contains

Hi everyone I have a table of contacts that have various Types attributed to them. For example, the Type could be Type A, AA, AAA, B, BB, BBB etc (this is a multi-select field in my Dynamics CRM)....
  • tackytechtom's avatar
    1 year ago

    Hi jonclay ,

     

    How about this?

     

     

    Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnTUUXB0dFSK1QGyQUwICyKqo+DkBOY7OYGYQHYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Type = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Type", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Type], "AA") and Text.Contains([Type], "AAA") then 1 else 0)
    in
        #"Added Custom"

     

    In a nutshell, I just used a simple if clause...

     

    Let me know if this solves your issue 🙂

     

    /Tom
    https://www.tackytech.blog/
    https://www.instagram.com/tackytechtom/

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi jonclay ,

     

    Pls has your problem been solved? If so, accept the reply as a solution. This will make it easier for the future people to find the answer quickly.

    If not, please provide a more detailed description, preferably some virtual sample data, and the expected results.

     

    Best Regards,

    Stephen Tao