Locked lesson.
About this lesson
Knowing how to solve the issue, we are now ready to go and put this technique to the test in our sample model.
Exercise files
Download this lesson’s related exercise files.
Solving Many-To-Many Joins with Composite Keys - Practice.xlsx262.7 KB Solving Many-To-Many Joins with Composite Keys - Practice - Completed.xlsx
296.6 KB
Quick reference
Solving Many-To-Many Joins with Composite Keys - Practice
An overview of creating composite keys to deal with Many to Many join issues.
When to use
When one of your tables has two (or more) columns with repeating values which, when joined, create a unique value.
Instructions
Creating a Composite Key column
For each table you wish to join:
- Edit your query in Power Query
- Select the columns you wish to merge together
- Go to Add Column --> Merge
- Choose to use a separator (such as a dash)
- Rename the column as desired
Using a Composite Key column
- Ensure you have a Composite Key column on both tables to be linked
- Ensure that the Composite Key column on one of the tables contains unique values
- Link the tables together using the Composite Key columns
- Hide the field on the Many side of the relationship (the side with the *)
Hints & tips
- To keep the original columns along with the new column, use the Merge operation in the Add Column tab instead of in the Transform tab
- Remember that the order in which the columns are selected is the order in which the data will appear in the new column
- It is recommended that the composite key field be hidden from all tables, as it is one that will never be used in the Pivot Table
- To ensure a column contains unique values in Power Pivot, use the Remove Duplicates feature on the column in Power Query
- This technique can work well on its own but may also be used in conjunction with bridge tables, covered in the section on Solving Many to Many Joins with Bridge Tables
Lesson notes are only available for subscribers.