Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to add a column from a different table

Hi all, 

 

I have a simple question regarding Power Query. 

 

I am working on two tables. Tables have in common a column, and the link is made between the 2 tables. 

I'd like to add to table 1 a column of table 2, in PowerQuery. 

 

I cannot share my data since it is for business matt

  • Anonymous - If you prefer a visual representation of what Anonymous is describing...

     

     

2 Replies

  • KNP's avatar
    KNP
    Super User

    Anonymous - If you prefer a visual representation of what Anonymous is describing...

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

     If i follow correctly you just want to merge the 2 tables and expand the column required

     

    #"Merged Queries" = Table.NestedJoin(#"Renamed Columns", {"REP"}, PM_User, {"UserCode"}, "PM_User", JoinKind.LeftOuter),
    #"Expanded PM_User" = Table.ExpandTableColumn(#"Merged Queries", "PM_User", {"UserName"}, {"PM_User.UserName"})

     

    or

     

    #"Merged Queries" = Table.NestedJoin(#"PreviousStepHere", {"Table1Column"}, Table2NameHere, {"Table2Column"}, "Table2NameHere", JoinKind.LeftOuter),
    #"Expanded Table2NameHere" = Table.ExpandTableColumn(#"Merged Queries", "Table2NameHere", {"ColumnYouWantToAdd"}, {"ColumnYouWantToAdd"})

     

    this would give you the column 'ColumnYouWantToAdd' from Table 2 added to Table 1