Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Find missing records between two tables

Hello all,   I have two different data sources in two different databases / languages. What I want to do is use Powerbi to automate & find which records  are missing from database 2. Database 1 w...
  • edhans's avatar
    6 years ago

    Do an ANTI-JOIN in Power Query.

    1. Select the first table. You can create a reference to that table if you don't want to distrupt that table first.
    2. Select the Merge button on the Home Ribbon
    3. Configure the dialog box as below. My Database 1 Customers (2) is because I created a reference.

    It returns this:

     

    If you want to see the M code doing this, create a blank query and put this code in:

    1) In Power Query, select New Source, then Blank Query
    2) On the Home ribbon, select "Advanced Editor" button
    3) Remove everything you see, then paste the M code I've given you in that box.
    4) Press Done

    let
        Source = #"Database 1 - Customers",
        #"Merged Queries" = Table.NestedJoin(Source, {"CustomerID"}, #"database 2 - clientcustomers", {"CustomerID"}, "database 2 - clientcustomers", JoinKind.LeftAnti),
        #"Removed Columns" = Table.RemoveColumns(#"Merged Queries",{"database 2 - clientcustomers"})
    in
        #"Removed Columns"