Locked lesson.
About this lesson
Since there are so many joins, it really pays to explore them all. In this lesson we will look at the Left Outer, Right Outer, Full Outer and Inner joins, as well as show a trick for joining on composite keys.
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.
Outer and Inner Joins.xlsx25.7 KB Outer and Inner Joins - Completed.xlsx
41.9 KB
Quick reference
Outer and Inner Joins
A demonstration of merging using Outer and Inner Joins.
When to use
When you want to merge two tables of data, returning records from the first table and any matching records from 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 columns to use as the merge key (i.e. the ones where the values 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
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.