Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jeffreyjar
Helper II
Helper II

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  

I have an issue on matching 2 columns in different tables 

 

Need help asap

 

 

the old column is "Numero Agents" of the table "APE 02 2022" base on their name

 

 

Numero Agents Noms Agents 
5599000DIRECT BUSINESS
5599000DIRECT BUSINESS
5599000DIRECT BUSINESS
5599000DIRECT BUSINESS
A10299002MENDOUME ERIC VALENTIN
94202301EXPRESS INSURANCE
B50199001YONDO MIYENGA ALICE
A10199018LEHMAN CHARLES FREDERIC
A10199012JIGHEULA WELAPINOU ELIONOR
A10101001NEMY OMOG SERGE FRANCOIS
A10199015NGUEKENG JOLIVETTE LUCIE
A10199012JIGHEULA WELAPINOU ELIONOR
A10199012JIGHEULA WELAPINOU ELIONOR
A10199012JIGHEULA WELAPINOU ELIONOR
A10199006NGONKOLO MARIE MADELEINE
A10199006NGONKOLO MARIE MADELEINE
A10199012JIGHEULA WELAPINOU ELIONOR
A10199006NGONKOLO MARIE MADELEINE
A10101001NEMY OMOG SERGE FRANCOIS
A10199001MBA NEE TENE LEOPOLDINE
A10199015NGUEKENG JOLIVETTE LUCIE

 

 

with this new column  "New Agents Codes" from the table "agent list" base on their name

 

New Agents CodesEAAGTNAME 
A10199003RHODE DORETTE MOSSI EKAME
A10199006NGONKOLO MARIE MADELEINE
A10199007HONTCHEU MONKAM DOMINIQUE
A10199010BEKONO KOMBO JEANNINE CHARLENE
A10199012JIGHEULA WELAPINOU ELIONOR
A10199013SAFEDIEU EDITH VADES
A10199015NGUEKENG JOLIVETTE LUCIE
A10199017NDO FOUDA BERNADETTE CHRISTALE
A10199018LEHMAN CHARLES FREDERIC
A10299002MENDOUME ERIC VALENTIN
A10299004MENI CAROLLE NELLY
A10299005MATHA DORIANNE CLAIRE
A10299006BELLA AWONO ANTOINE ALFRED
A10299007BIENDU KOUAGHU MIKEL FLORE
A10299008TCHANA KUIGOUA EDWIGE
A10299010MANDONG CHRYSTELLE NICOLE
A10299011DJUIDJE FOGAING MARIE CHRISTEL
A10299012MBOM LOTIN BERTHY AURELIE
A10299013NYANDJOU TCHOUMGA PATRICK B.
A10399002TCHAOU STEPHANE
A10399003TCHAMBA NGAHA DONALD
A10399004TCHEUFANG FALONNE
A10399006MANET CHRISTINE PERSIDE GRACE
A10399015CHEBOU CHEKEM ELIANE JOCELYN
A10399016IKOU WELNJEL DANIEL HERVE
A10399018AWOUMOU NGA OWONA VANESSA
1 ACCEPTED SOLUTION
hokeson
Employee
Employee

 

 

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 

hokeson_0-1656315074738.png

 

View solution in original post

2 REPLIES 2
hokeson
Employee
Employee

 

 

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 

hokeson_0-1656315074738.png

 

hokeson
Employee
Employee

Hello,

you can use a formula comparing values and returning requested result. Do you have some sample data and expected result?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.