Hello, young data explorer! Welcome to Module Eight. In this module, we will learn how to combine data from different places. Imagine you have two puzzle pieces. Alone, they don't show the whole picture. But when you join them together, you see the complete image. That's what combining data does โ it brings together information from different tables to give you a full story. We will learn about merging (like joining two lists side by side) and appending (like stacking one list on top of another). By the end of this module, you will be a Data Puzzle Master!
Ngozi is the class prefect. She has two lists. List A has student names and their test scores. List B has student names and their project scores. But the lists are separate. Ngozi wants to see each student's total score (test + project). She decides to combine the two lists. She matches each student from List A with the same student in List B. If a student is missing in one list, she writes "Absent". After combining, she has a complete table with all scores. That's what we will do with Power Query โ combine tables to see the whole picture!
Definition: Combining data means taking two or more tables and joining them together.
Why important: Often your data is spread across different files. Combining helps you see everything in one place.
Simple explanation: It's like putting together pieces of a jigsaw puzzle to see the complete picture.
Real-life example: A company has a table of employees and a table of salaries. They combine them to get a full employee record.
School example: You have a list of students and a list of their favourite subjects. Combining gives you a list with both.
Home example: You have a list of family members and a list of their birthdays. Combine to see everyone's birthday.
Nigerian example: A bank has customer account details and transaction history. They combine them to see each customer's transactions.
Illustration:
Table 1 (Students) + Table 2 (Scores) = Combined Table +----+-------+ +----+-------+ +----+-------+-------+ | ID | Name | | ID | Score | | ID | Name | Score | +----+-------+ +----+-------+ +----+-------+-------+ | 1 | Bola | | 1 | 90 | | 1 | Bola | 90 | | 2 | Tunde | | 2 | 85 | | 2 | Tunde | 85 | +----+-------+ +----+-------+ +----+-------+-------+
Mini summary: Combining data brings separate tables together into one.
Definition: Merging adds columns from one table to another (side by side). Appending stacks rows from one table to another (top to bottom).
Why important: You need to know which method to use depending on what you want.
Simple explanation: Merging is like adding new clothes to your wardrobe (new columns). Appending is like adding more clothes of the same type (more rows).
Real-life example: Merging: adding phone numbers to a contact list. Appending: adding new contacts to the list.
School example: Merging: adding grades to student names. Appending: adding students from another class.
Home example: Merging: adding prices to grocery items. Appending: adding more grocery items.
Nigerian example: Merging: adding LGA to a list of states. Appending: adding data from another state.
Illustration:
Merging (side by side): Table A: ID, Name + Table B: ID, Age = Table C: ID, Name, Age Appending (top to bottom): Table A: ID, Name + Table B: ID, Name = Table C: ID, Name (more rows)
Mini summary: Merge = add columns. Append = add rows.
Definition: A key is a column that uniquely identifies each row (e.g., Student ID).
Why important: When merging, the key tells Power Query how to match rows from the two tables.
Simple explanation: It's like a secret code that two friends use to find each other in a crowd.
Real-life example: In a school, student ID is the key to match students with their grades.
School example: Your admission number is the key.
Home example: Your family member's name is a key to find their age.
Nigerian example: NIN (National Identification Number) is a key to match citizens with their records.
Illustration:
Table 1 (Key = ID) Table 2 (Key = ID) Merge on ID +----+-------+ +----+-------+ +----+-------+-------+ | ID | Name | | ID | Score | | ID | Name | Score | +----+-------+ +----+-------+ +----+-------+-------+ | 1 | Bola | | 1 | 90 | | 1 | Bola | 90 | | 2 | Tunde | | 2 | 85 | | 2 | Tunde | 85 | +----+-------+ +----+-------+ +----+-------+-------+
Mini summary: A key is a special column that matches rows from different tables.
Definition: Inner join keeps only rows that have a match in both tables.
Why important: Use this when you only want records that exist in both tables.
Simple explanation: If two friends both have the same secret code, they meet. If one doesn't have it, they don't meet.
Real-life example: You have a list of students and a list of those who paid fees. Inner join gives only students who have paid.
School example: List of subjects and list of teachers. Inner join gives subjects that have a teacher assigned.
Home example: List of family members and list of those who like pizza. Inner join gives family members who like pizza.
Nigerian example: Voter register and election results. Inner join gives only voters who voted.
Illustration:
Table A: ID, Name Table B: ID, Score 1, Bola 1, 90 2, Tunde 3, 88 โ ID 3 not in A Inner Join on ID โ only ID 1 (Bola, 90) because ID 2 in A but not in B? Actually ID 2 in A, not in B, so not kept. Result: ID 1: Bola, 90
Mini summary: Inner join keeps only rows that appear in both tables.
Definition: Left outer join keeps all rows from the left table, and matching rows from the right. If no match, right side is null (empty).
Why important: Use this when you don't want to lose any rows from the main table.
Simple explanation: The left table is the boss. It keeps all its rows. The right table is a friend โ if it has a match, it joins; if not, it leaves a blank.
Real-life example: You have a list of all students (left) and test scores (right). You want all students, even if they have no score.
School example: All students and their project scores. You want to see all students, even those who didn't submit a project.
Home example: Family members and their chores. You want all members, even if they have no chore.
Nigerian example: All customers and their orders. You want all customers, even those who haven't ordered.
Illustration:
Left Table: ID, Name Right Table: ID, Score 1, Bola 1, 90 2, Tunde 3, 88 3, Zain Left Outer Join โ all from left: 1, Bola, 90 2, Tunde, null (no score) 3, Zain, null (no score)
Mini summary: Left outer join keeps all rows from the left table.
Definition: Right outer join keeps all rows from the right table, and matching rows from the left. If no match, left side is null.
Why important: Use this when the right table is your main focus.
Simple explanation: Now the right table is the boss.
Real-life example: You have a list of products (right) and a list of sales (left). You want all products, even if they have no sales.
School example: Subjects (right) and teachers (left). You want all subjects, even if no teacher assigned.
Home example: Chores (right) and family members (left). You want all chores, even if no one does them.
Nigerian example: States (right) and governors (left). You want all states, even if some have no governor data.
Illustration:
Left Table: ID, Name Right Table: ID, Score
1, Bola 1, 90
2, Tunde 3, 88
4, 95
Right Outer Join โ all from right:
1, Bola, 90
3, null, 88
4, null, 95
Mini summary: Right outer join keeps all rows from the right table.
Definition: Full outer join keeps all rows from both tables. If a row doesn't have a match, the missing side is null.
Why important: Use when you want to see everything from both tables.
Simple explanation: Both tables are bosses. Everyone is included.
Real-life example: You have a list of employees and a list of departments. You want to see all employees and all departments, even if some employees are not assigned to a department.
School example: Students and clubs. You want all students and all clubs.
Home example: Family members and hobbies. You want all members and all hobbies.
Nigerian example: Companies and products. You want all companies and all products.
Illustration:
Left: 1, Bola ; 2, Tunde Right: 1, 90 ; 3, 88 Full Outer โ 1, Bola, 90 2, Tunde, null 3, null, 88
Mini summary: Full outer join keeps all rows from both tables.
Definition: Merging in Power Query is done using the "Merge Queries" button.
Why important: This is the main tool you will use to combine tables.
Simple explanation: It's like clicking a magic button that joins your tables.
Real-life example: You have two Excel sheets. You merge them to create one.
School example: You have a class list and a grade list. Merge to get grades for each student.
Home example: You have a grocery list and a price list. Merge to get total cost.
Nigerian example: You have a list of LGAs and a list of populations. Merge to have population per LGA.
How to do it: In Power Query, go to the "Home" tab, click "Merge Queries", select the two tables, choose the key column, and select the join type.
Illustration:
Step 1: Home โ Merge Queries Step 2: Select Table 1 and Table 2 Step 3: Choose key column (e.g., ID) from each Step 4: Choose join type (Inner, Left, etc.) Step 5: Click OK โ new column with nested tables Step 6: Expand the new column to get the data.
Mini summary: Merge Queries is the tool to combine tables in Power Query.
Definition: Appending adds rows from one table to another. Both tables must have the same column structure.
Why important: Use this when you have data split across multiple files (e.g., sales by month).
Simple explanation: It's like stacking books on top of each other.
Real-life example: You have sales for January in one file and sales for February in another. Append them to get all sales.
School example: Class A attendance and Class B attendance. Append to get total attendance.
Home example: Expenses for week 1 and week 2. Append to get monthly expenses.
Nigerian example: COVID-19 data for Lagos and COVID-19 data for Abuja. Append to get national data.
How to do it: Home tab โ Append Queries โ Select the tables to append.
Illustration:
Table A: ID, Name Table B: ID, Name Append โ
1, Bola 3, Zain 1, Bola
2, Tunde 4, Amina 2, Tunde
3, Zain
4, Amina
Mini summary: Append stacks rows.
Definition: Power Query can combine all files in a folder (e.g., all CSV files).
Why important: Saves time when you have many files.
Simple explanation: It's like putting all your toys from different boxes into one big toy box.
Real-life example: A company has daily sales files for a year. Power Query combines them into one table.
School example: You have homework files for each subject. Combine them into one file.
Home example: You have photos from different holidays. Combine them into one album.
Nigerian example: A bank has monthly account statements. Combine them into yearly statement.
How to do it: Get Data โ From Folder โ Browse to folder โ Combine & Transform.
Illustration:
Folder: Sales
|-- Jan.csv
|-- Feb.csv
|-- Mar.csv
...
Power Query combines all into one Sales table.
Mini summary: Combine from folder is a powerful way to merge many files.
Definition: Mismatched keys happen when the key column has different values in the two tables (e.g., "1" vs "01").
Why important: If keys don't match, your merge will be wrong.
Simple explanation: If two friends have different secret codes, they can't find each other.
Real-life example: Student ID in one table is "100" and in another is "00100". They don't match.
School example: Your name is "Tunde" in one list and "Tunde O." in another. Not exactly the same.
Home example: "Dad" in one list and "Father" in another.
Nigerian example: Phone number has different formats (080 vs +23480).
How to fix: Before merging, transform the key columns to be the same (e.g., trim, format, convert to text).
Illustration:
Table A: ID = "001" Table B: ID = "1" โ Convert both to text and trim. Then they match: "001" and "1" are different, so we might need to convert to number: 1 and 1 match.
Mini summary: Always ensure keys match exactly before merging.
Definition: After a merge, Power Query creates a new column containing nested tables. You need to expand it to see the data.
Why important: Without expanding, you only see the word "Table".
Simple explanation: It's like opening a gift box to see the present inside.
Real-life example: You merged, and you see a column with "Table". Click the expand icon to get the actual data.
School example: You merged grades, and you see "Table". Expand to see scores.
Home example: You merged prices, and you see "Table". Expand to see prices.
Nigerian example: You merged populations, expand to see population numbers.
How to do it: Click the expand icon (two arrows) on the new column header, select the columns you want, and click OK.
Illustration:
After Merge: +----+-------+-------------+ | ID | Name | Merged | +----+-------+-------------+ | 1 | Bola | Table | โ Click expand +----+-------+-------------+ After Expand: +----+-------+-------+ | ID | Name | Score | +----+-------+-------+ | 1 | Bola | 90 | +----+-------+-------+
Mini summary: Expand nested tables to see the actual data.
Definition: Sometimes you need to match on two or more columns (e.g., First Name and Last Name).
Why important: Single key might not be unique.
Simple explanation: You use two clues to find your friend: name and age.
Real-life example: Match customers by first name and last name together.
School example: Match students by class and roll number.
Home example: Match chores by day and person.
Nigerian example: Match citizens by state and LGA.
How to do it: In the merge dialog, select multiple columns from each table (hold Ctrl to select multiple).
Illustration:
Table A: First, Last, Age Table B: First, Last, Score Merge on First AND Last.
Mini summary: You can merge on multiple columns for a better match.
Definition: Fuzzy matching allows matches even if the key is not exactly the same (e.g., "Bola" and "Bolah").
Why important: Handles typos or slight differences.
Simple explanation: It's like guessing a friend's name even if you spell it a little wrong.
Real-life example: "Ade" and "Adeyemi" might be matched.
School example: "Maths" and "Mathematics" might be matched.
Home example: "Soda" and "Pop" might be matched.
Nigerian example: "Lagos" and "Lag" might be matched.
How to do it: In merge dialog, check "Use fuzzy matching" and adjust similarity threshold.
Illustration:
Table A: "Bola" Table B: "Bolah" Fuzzy match โ treated as same.
Mini summary: Fuzzy matching helps when data has small differences.
Definition: Follow these tips for successful data combining.
Why important: Avoids errors and makes your work easier.
Simple explanation: Like following a recipe to bake a perfect cake.
Illustration:
Best Practice Flow: 1. Clean keys (trim, remove spaces) 2. Decide merge or append 3. Perform merge/append 4. Expand if needed 5. Check result 6. Rename columns
Mini summary: Good planning leads to successful combining.
How to Merge Two Tables:
How to Append Two Tables:
Did you know that Power Query can combine data from thousands of files in a folder in just a few clicks? That's powerful!
Merge (side by side):
+-------+-------+ +-------+-------+ +-------+-------+-------+
| ID | Name | | ID | Score | | ID | Name | Score |
+-------+-------+ +-------+-------+ +-------+-------+-------+
| 1 | Bola | | 1 | 90 | | 1 | Bola | 90 |
| 2 | Tunde | | 2 | 85 | | 2 | Tunde | 85 |
+-------+-------+ +-------+-------+ +-------+-------+-------+
Append (top to bottom):
+-------+-------+ +-------+-------+ +-------+-------+
| ID | Name | | ID | Name | | ID | Name |
+-------+-------+ +-------+-------+ +-------+-------+
| 1 | Bola | | 3 | Zain | | 1 | Bola |
| 2 | Tunde | | 4 | Amina | | 2 | Tunde |
+-------+-------+ +-------+-------+ | 3 | Zain |
| 4 | Amina |
+-------+-------+
Inner Join: Keeps only matching rows. Left Outer: Keeps all from left, matches from right. Right Outer: Keeps all from right, matches from left. Full Outer: Keeps all from both.
| Feature | Merge | Append |
|---|---|---|
| What it adds | Columns | Rows |
| Requires | Key column | Same column structure |
| Use when | You want to combine different information | You want to combine same information from different sources |
| Join Type | Keeps | Use case |
|---|---|---|
| Inner | Only matches | When you need only common records |
| Left Outer | All from left | When left table is main |
| Right Outer | All from right | When right table is main |
| Full Outer | All from both | When you need everything |
Congratulations! You have completed Module Eight on Combining Data. You learned:
Combining data is like being a master puzzle solver. You take different pieces and put them together to see the big picture. Now you can combine any data with confidence!
Match the term to its definition:
| Term | Definition |
|---|---|
| 1. Merge | A. Add rows |
| 2. Append | B. Add columns |
| 3. Key | C. Approximate match |
| 4. Inner Join | D. Unique identifier |
| 5. Fuzzy Matching | E. Keep only matches |
Answers: 1-B, 2-A, 3-D, 4-E, 5-C
Scenario 1: You have a table of students (ID, Name) and a table of grades (ID, Grade). You want a table with all students and their grades, but some students have no grade. Which join would you use? Write the steps.
Scenario 2: You have sales data for January and February in separate files. Both files have the same columns. How would you combine them? What is this operation called?
In groups, get two sample datasets (e.g., customer data and order data). Decide which join type to use. Perform the merge in Power Query. Present the result to the class.
Create two small tables in Excel: one with student IDs and names, another with student IDs and scores. Import them into Power Query, perform a Left Outer Join, and expand the result.
Project: Combine Sales Data
You have sales data for four quarters (Q1, Q2, Q3, Q4) in separate Excel files. Each file has the same columns: Product, Salesperson, Amount. Combine all four files into one table using Power Query (append). Then, merge this with a product details table (Product, Category) to add category information. Present the final combined table.
Download two datasets from the internet (e.g., customer list and purchase history). Use Power Query to:
You have three tables: Students (ID, Name), Subjects (SubjectID, SubjectName), and Scores (ID, SubjectID, Score). Write the steps to combine all three tables into one table that shows each student's name, subject, and score. Which joins would you use? Perform the steps in Power Query.
Fill-in-the-Blank: 1. Merge, 2. Append, 3. key, 4. Inner, 5. Left Outer
True/False: 1-F, 2-F, 3-T, 4-F, 5-T
Matching: 1-B, 2-A, 3-D, 4-E, 5-C
In Module Nine, we will learn about Grouping and Aggregating data. We will summarize data (like total sales per product) and group rows to get insights. Get ready to become a Data Summarizer!
Before the next class, practice merging and appending with different datasets. Try to combine data from at least two different sources.
ยฉ 2025 Certified Power Query for Data Analysis Expert โ Module Eight