Forum Discussion

franktby's avatar
franktby
Frequent Visitor
7 years ago
Solved

Customize a table combine with two tables

Hi:

    I have two tables and I want to create columns of them:

 

Table A:

phone_number    address

123                       abc

124                       asd

156                       aer

 

Table B:

phone_number    name

123                       frank

124                       Tim

188                       Jim

 

Basiclly I have table B and I'm trying to find the people's address on table A based on his phone number, the address might not there.

 

The result I want:

 

Table C:

name          phone_number      address

frank           123                        abc

Tim             124                        asd

 

 

Thanks

 

  • Hi franktby,

     

    We can merge table  A and table B in Power query as the picture below.

     

    Here is the M code in Advanced Editor for your reference.

     

    let
        Source = Table.NestedJoin(TableA,{"phone_numbe"},TableB,{"phone_numbe"},"TableB",JoinKind.LeftOuter),
        #"Expanded TableB" = Table.ExpandTableColumn(Source, "TableB", {"name"}, {"TableB.name"}),
        #"Filtered Rows" = Table.SelectRows(#"Expanded TableB", each ([TableB.name] <> null))
    in
        #"Filtered Rows"

    Also please find the file attached.

     

    Regards,
    Frank

1 Reply

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi franktby,

     

    We can merge table  A and table B in Power query as the picture below.

     

    Here is the M code in Advanced Editor for your reference.

     

    let
        Source = Table.NestedJoin(TableA,{"phone_numbe"},TableB,{"phone_numbe"},"TableB",JoinKind.LeftOuter),
        #"Expanded TableB" = Table.ExpandTableColumn(Source, "TableB", {"name"}, {"TableB.name"}),
        #"Filtered Rows" = Table.SelectRows(#"Expanded TableB", each ([TableB.name] <> null))
    in
        #"Filtered Rows"

    Also please find the file attached.

     

    Regards,
    Frank