Forum Discussion

Jeffreyjar's avatar
Jeffreyjar
Icon for Helper II rankHelper II
4 years ago
Solved

Match 2 columns from different columns

Hello,    I'm kind of new in power bi so im doing small projects to perform myself,  im doing a ranking of each agents of a company and each agent has his own code and it is changing every time   ...
  • hokeson's avatar
    4 years ago

     

     

    First step you need to do is to deduplicate records in table APE 02 2022.

    then you can merge both table based on name to get all combinations.

    it depends of usecase. 

     

    please see M-code for deduplication

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tZHBasMwEER/ZfE5B9mtS3NU7KmzibQbJCutCfn/3+jKlEJ6KDQ0CHTZtzPD7OXS9P1265xrNs3ICcNMu5JZkHNz3Txy6lvX1Xln8wgZtUQQEg909gEys6zY9rlz3ZNrjcLHKdk2seSSvAxYgV3v2qpTiUVNhyIvkMmTD/zFmFdl2ldjAvbRCw17nwIyvSWM1fWGq5kOPO1Rgqd3BH9i0UIIrKLpG7W32griQhp1oow0wTQtnXK+0ewrOBUcLRsdNPAZ8wwKZWDcY/4w1L2sSVWOGqxMnxj2jwiw490F/rv5X4pfwbjzJADNEKscetIw/gz5+4Gunw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Numero Agents " = _t, #"Noms Agents" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Numero Agents ", type text}, {"Noms Agents", type text}}),
        #"Removed Duplicates" = Table.Distinct(#"Changed Type", {"Numero Agents "})
    in
        #"Removed Duplicates"

     

     

    see M-code for merge

     

    let
        Source = Table.NestedJoin(#"New Agents codes", {"EAAGTNAME"}, #"APE 02 2022", {"Noms Agents"}, "APE 02 2022", JoinKind.FullOuter),
        #"Expanded APE 02 2022" = Table.ExpandTableColumn(Source, "APE 02 2022", {"Numero Agents ", "Noms Agents"}, {"Numero Agents ", "Noms Agents"})
    in
        #"Expanded APE 02 2022"

     

    result looks like