Locked lesson.
About this lesson
Some of the most powerful joins for those trying to perform reconciliations are those that identify the items that do NOT match. In this case we will explore how the Left Anti, Right Anti and Full Anti joins can be used to accomplish this.
Exercise files
Download this lesson’s related exercise files. You can download source data files for the course from the resources section of your Lessons page.
Anti Joins.xlsx25.6 KB Anti Joins - Completed.xlsx
30.6 KB
Quick reference
Anti Joins
A demonstration of merging using Anti Joins.
When to use
When you want to compare two tables and identify which records in the first table do not have a match in the second table.
Instructions
Create staging queries for the source data tables
For each data source
- Create a new query that points to the data source
- Perform whatever transformations are required to clean up the data
- Finalize the query by choosing Home --> Close & Load To… --> Only Create Connection
Merge the staging queries
- Open the Queries & Connections pane in Excel
- Right click one of the tables you wish to merge --> Merge
- Choose the other table you wish to merge
- Select the column to use as the merge key (i.e. the one with values that are the same in both tables so that Power Query knows which records to match together) in both tables
- Choose the Join Kind and click OK
- Rename the newly created query
- Expand the new column(s) and choose which data to include
- Define the data types for the columns
- Finalize the query by loading it to the desired destination
Creating a Full Anti Join
- Create merged table with a Left Anti Join
- Create a merged table with a Right Anti Join
- Append the two tables together
Hints & tips
- A merge key that is based on multiple columns is called a concatenated key
- The order in which you select the columns for creating the merge key is important, so make sure you select them in the same order for both columns
- For non-subscription versions of Excel 2016, there is no option to select the join type when merging as only Left Outer Joins are available
- To create the other join types, first build a merge with a Left Outer Join and then manually change the merge type in the formula bar
Lesson notes are only available for subscribers.