Forum Discussion

kazael's avatar
kazael
Helper I
7 years ago
Solved

How to join a table with a subquery using power query M

Hi, I have two tables that I'd like to merge: Table 1: Complaints, employee ID Table 2: Employee ID, Emp first name, Emp last name I'd like to join table1 with a subquery of table2 with power que...
  • Greg_Deckler's avatar
    Greg_Deckler
    7 years ago

    Well, if you don't want to write M code to keep it all in one query, you could simply create a new reference query to Table1. Right click Table1 query and choose "Reference". Then in that query right-click the EmpID column and choose to remove duplicates. Then just use that table in your merge query. Or you could just write those steps in M and keep it all in a single query without creating the table, but however you want to do it. For example something like this would probably work:

     

    = Table.NestedJoin(Table.Distinct(Table1,{"EmpID"}),{"EmpID"},Table2,{"EmpID"},"Table2",JoinKind.LeftOuter)