Forum Discussion

NSBS's avatar
NSBS
Helper I
4 years ago
Solved

Comparing 2 tables in M Language

Hi,   I have 2 tables as per below and I want to create a M code which compare the Country List Table with the Country Code Reference Tabel and give me the Comparison Column as the result (True is ...
  • PC2790's avatar
    PC2790
    4 years ago

    I interpreted your requirement wrongly. You can add a new column in Country List table as below:

    = Table.AddColumn(Source, "Match", each List.Contains(#"Country Code Reference"[Country List], [Country List]), type logical)

     

    Here is the code to do it:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRTitUBUj5gysUFQkVBBIMhFETQ0V0pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Country List" = _t]),
        Custom1 = Table.AddColumn(Source, "Match", each List.Contains(#"Country Code Reference"[Country List], [Country List]), type logical)
    in
        Custom1