Welcome, young data explorer! In this module, we will learn how to take messy, mixed‑up data and turn it into neat, tidy tables – just like arranging your toys in the right boxes. We call this “data cleaning” and “data shaping”. Power Query is like a magic kitchen where we chop, mix, and cook raw ingredients (data) into a delicious meal (clean information). By the end of this chapter, you will be able to fix errors, split names, join tables, and make your data ready for answers.
Ade loves helping his grandma in the kitchen. One day, Grandma said, “Ade, please mix the spices for the jollof rice – but each spice is in a different bag, and some bags are not labelled!” Ade found bags with “salt”, “pepper”, “curry”, and one bag just said “????”. He had to sort, taste, and mix everything carefully. When he finished, the jollof rice was perfect!
Data is like those spices. It comes from different places, sometimes with missing labels. Power Query is your mixing bowl – it helps you sort, rename, and blend everything so you can cook up the right answers!
Definition: Data cleaning means fixing mistakes and removing things that don’t belong in your data table.
Why important: If your data is dirty, your answers will be wrong – like using salt instead of sugar in a cake!
Simple explanation: Imagine your school’s list of students has some names spelled wrong and some blank rows. Cleaning means you correct the names and delete the empty rows.
Real‑life example: A shopkeeper checks his sales list – some prices are missing, so he fills them in.
School example: The class register has two “Mary” entries – one is Mary A., the other Mary B. You fix it.
Home example: Your mom’s grocery list has “milk” written twice – you cross out the extra one.
Nigerian example: A local market seller records sales on paper. Some numbers are faded; she rewrites them clearly before typing into Excel.
Dirty data → Clean data "2,0" → 20 "N/A" → (empty) "LAGOS" → "Lagos"
Mini summary: Cleaning = fixing errors and removing clutter so your data tells the truth.
Definition: Empty rows are blank lines in your table. Empty columns have no data at all.
Why important: They waste space and can confuse Power Query.
Simple explanation: Like having empty chairs in a classroom – you don’t count them when taking attendance.
Real‑life example: A phone book with blank pages – you skip them.
School example: Your teacher’s mark sheet has empty rows for absent students – she removes them.
Home example: A list of chores with a blank line – you delete it.
Nigerian example: A Lagos bus conductor’s daily passenger count may have blank rows for trips that didn’t happen; he removes them.
How to in Power Query: Home → Remove Rows → Remove Blank Rows.
Before: Row1: Ade, 10 Row2: (blank) Row3: Bola, 12 After: Row1: Ade, 10 Row2: Bola, 12
Mini summary: Blank rows are like empty seats – take them out!
Definition: This means making sure all names and words are spelled the same way and have proper capital letters.
Why important: “LAGOS” and “lagos” are the same city – but the computer thinks they are different if we don’t fix them.
Simple explanation: Like writing your name with a capital letter – “Ade” not “ade”.
School example: Your class list has “John” and “jon” – you change both to “John”.
Home example: Your dad’s contact list has “Mum” and “mum” – you make them both “Mum”.
Nigerian example: Abuja is sometimes written “abuja” – we change it to “Abuja”.
Before: "ikeja", "IKEJA", "Ikeja" After: "Ikeja", "Ikeja", "Ikeja"
Mini summary: Always use the same spelling and capitals so your data stays neat.
Definition: Splitting means taking one column and dividing it into two columns – like separating first name and last name.
Why important: It helps you sort by last name or first name separately.
Simple explanation: Like separating your full name “Ade Ojo” into “Ade” and “Ojo”.
Real‑life example: A list of customers has “Mr. Ade Ojo” – you split into title, first name, last name.
School example: The teacher has “Maryam Bello” – split into “Maryam” and “Bello”.
Home example: “Chicken and rice” – split into “Chicken” and “rice”.
Nigerian example: “Lagos, Nigeria” – split into “Lagos” and “Nigeria”.
How to: Transform → Split Column → By Delimiter (e.g., space or comma).
FullName → FirstName LastName Ade Ojo → Ade Ojo Funke Ade → Funke Ade
Mini summary: Split separates data into smaller pieces for better handling.
Definition: Merging is the opposite of splitting – you combine two columns into one.
Why important: Sometimes you want a full name instead of separate first and last.
Simple explanation: Like putting two puzzle pieces together to see the whole picture.
School example: You have “First” and “Last” – merge to “Full Name”.
Home example: “Street” and “City” merge to “Address”.
Nigerian example: “State” and “LGA” merge to “Location”.
First Last → FullName Ade Ojo → Ade Ojo
Mini summary: Merging puts pieces back together when needed.
Definition: Data type tells Power Query what kind of data is in a column – words (text), numbers, or dates.
Why important: You can’t add text like “ten” to a number – the computer needs to know.
Simple explanation: Like sorting toys into boxes – words in one box, numbers in another.
Real‑life example: “1,000” as text vs. 1000 as a number – you can only add numbers.
School example: Marks are numbers, names are text – don’t mix them.
Home example: Date of birth is a date; age is a number.
Nigerian example: “₦500” is text (has symbol) but we need the number 500 to add prices.
Text: "10" → Number: 10 Date: "01/01/2025" → Date type
Mini summary: Always set the right data type so Power Query understands your data.
Definition: Fill Down takes a value from a cell and copies it into the empty cells below it.
Why important: In some tables, the value is only written once, but it applies to many rows.
Simple explanation: Like when your teacher says “Class 4” at the top – it means all students are in Class 4.
School example: A register with “Year 5” at the top – fill down so every row has “Year 5”.
Home example: A grocery list with “Store: Shoprite” at the top – fill down for all items.
Nigerian example: A list of students from “Lagos State” – fill down so all rows show Lagos.
Before: After: Region Region North North (blank) North South South (blank) South
Mini summary: Fill Down saves time – copy once, paste many!
Definition: A custom column is a new column you build using a formula, like combining or calculating.
Why important: It lets you create new information from existing columns.
Simple explanation: Like making a fruit salad – you take apples and oranges and mix them into a new dish.
School example: You have “Maths” and “English” marks – create a “Total” column by adding them.
Home example: You have “Price” and “Quantity” – create “Total Cost” = Price × Quantity.
Nigerian example: You have “Naira” and “Kobo” – create “Total Amount” in Naira.
Price Quantity → TotalCost 100 3 → 300 200 2 → 400
Mini summary: Custom columns let you create new facts from your data.
Definition: Merging tables means bringing two tables together based on a common column (like a student ID).
Why important: Sometimes information about the same thing is in two places – merging brings it together.
Simple explanation: Like having your friends’ names in one list and their phone numbers in another – you combine them.
School example: Table 1: Student ID and Name. Table 2: Student ID and Marks. Merge to get Name + Marks.
Home example: Table 1: Item names. Table 2: Prices. Merge to see item + price.
Nigerian example: Table 1: LGA names. Table 2: LGA population. Merge to get LGA + population.
Table1 (ID, Name) + Table2 (ID, Age) → Merged (ID, Name, Age) 1, Ade 1, 10 → 1, Ade, 10 2, Bola 2, 12 → 2, Bola, 12
Mini summary: Merging joins two tables using a shared key column.
Definition: Pivot turns rows into columns. Unpivot turns columns into rows.
Why important: Sometimes data is easier to read in a different shape.
Simple explanation: Like turning a line of people into a circle – same people, different arrangement.
School example: You have subjects as columns – pivot to make subjects rows.
Home example: You have months as columns – pivot to make months rows for easier charting.
Nigerian example: Sales data with months as columns – pivot to analyse by month.
Before (wide): Student Maths English Ade 80 70 After (long): Student Subject Marks Ade Maths 80 Ade English 70
Mini summary: Pivot and unpivot change how your table looks, not the data itself.
Definition: Replacing means swapping one value with another – like changing “N/A” to blank.
Why important: It standardises data so everything is consistent.
Simple explanation: Like changing “Mum” to “Mother” everywhere.
School example: Replace “Abs” with “Absent”.
Home example: Replace “fridge” with “refrigerator”.
Nigerian example: Replace “LAG” with “Lagos”.
Before: "LAG", "Lagos", "lagos" After: "Lagos", "Lagos", "Lagos"
Mini summary: Replace fixes inconsistent words quickly.
Definition: You can choose to remove columns you don’t need.
Why important: Fewer columns make it easier to focus on what matters.
Simple explanation: Like choosing only your favourite toys to play with.
School example: A report card has many columns – keep only Name and Total.
Home example: Shopping list with price, quantity, and aisle – keep only price and quantity.
Nigerian example: Population data with many details – keep only State and Population.
Before: ID, Name, Age, Grade, Teacher After: Name, Grade (removed ID, Age, Teacher)
Mini summary: Keep only the columns that answer your question.
Definition: Sorting arranges rows in order (A→Z, smallest→largest). Filtering shows only rows that meet a condition.
Why important: It helps you find the top scores or see only a specific group.
Simple explanation: Like lining up from shortest to tallest (sorting) or only picking kids who wear glasses (filtering).
School example: Sort marks from highest to lowest; filter to see only students with marks above 80.
Home example: Sort grocery list alphabetically; filter to show only fruits.
Nigerian example: Sort states by population; filter to show only states in the South‑South.
Sort: 5, 3, 9 → 3, 5, 9 Filter: [10, 20, 30] > 20 → [30]
Mini summary: Sorting and filtering help you find the data you need quickly.
Definition: Group By takes rows with the same value and summarises them – like counting or summing.
Why important: It gives you totals by category – like total sales per region.
Simple explanation: Like grouping your toys by colour and counting how many of each colour.
School example: Group students by class and count how many in each class.
Home example: Group shopping items by category (fruits, vegetables) and count.
Nigerian example: Group sales by state and find total sales per state.
Before: (Ade, Lagos), (Bola, Lagos), (Tunde, Abuja) After Group By State: Lagos: 2 Abuja: 1
Mini summary: Group By summarises data by categories.
Definition: Undo takes back your last step. Redo puts it back again.
Why important: You can experiment without fear – if you make a mistake, just undo!
Simple explanation: Like erasing a wrong answer and writing it again.
School example: You delete a column by mistake – undo brings it back.
Home example: You change “rice” to “beans” – undo changes it back.
Nigerian example: You replaced all “Lagos” with “Abuja” – undo to fix.
How to: Use the “Undo” button or Ctrl+Z.
Mini summary: Undo is your safety net – always available!
Data Cleaning Process
+-------------------+
| Dirty Data |
| (spelling errors,|
| blanks, mixed) |
+--------+----------+
|
V
+--------+----------+
| Clean Steps |
| - Remove blanks |
| - Fix spelling |
| - Split columns |
+--------+----------+
|
V
+--------+----------+
| Clean Data |
| (neat, correct, |
| ready to use) |
+-------------------+
Split Column – before and after +-----------------+ +-----------------+-----------------+ | FullName | | FirstName | LastName | +-----------------+ +-----------------+-----------------+ | Ade Ojo | → | Ade | Ojo | +-----------------+ +-----------------+-----------------+
| Operation | Use | Example |
|---|---|---|
| Split | Separate one column into two | FullName → First, Last |
| Merge | Combine two columns into one | First + Last → FullName |
| Group By | Summarise by category | Count students per class |
| Pivot | Rows to columns | Subject names as columns |
In this module, we learned how to make our data beautiful and useful. We removed blank rows, fixed spelling, split and merged columns, changed data types, used Fill Down, created custom columns, and even merged tables. We also explored Pivot, Unpivot, Group By, and sorting. Remember – clean data leads to correct answers. Always check your data types and keep only what you need. You are now ready to turn messy data into a clear story!
Match the term with its description:
| Term | Description |
|---|---|
| 1. Split | A. Combine two tables |
| 2. Merge | B. Separate one column into two |
| 3. Pivot | C. Turns rows into columns |
| 4. Group By | D. Summarise by category |
Answers: 1-B, 2-A, 3-C, 4-D
Scenario 1: You have a list of 100 students with names like “Ade Ojo”, “Bola”, “Chidi Eze” (missing last name). How would you clean this? (Answer: split full name where possible, leave missing as blank or fix manually.)
Scenario 2: Your teacher gave you two tables – one with student IDs and names, another with student IDs and test scores. How can you combine them? (Answer: merge on Student ID.)
In small groups, create a messy data table with at least 10 rows and 4 columns (include spelling errors, blanks, mixed capitals). Exchange tables with another group and clean each other’s data using the steps learned.
Open Excel or Power Query (if available). Take the class attendance list and clean it: remove empty rows, fix names, and change the date column to Date type.
Collect data from your classmates: Name, Age, Favourite Subject, and Score in Maths (out of 100). Type it into Excel. Use Power Query to: (1) Remove blank rows, (2) Split name into first and last, (3) Change Age to number, (4) Sort by Score descending. Show your clean table.
Download a sample dataset from the internet (or use a provided one). Clean it using at least 5 different operations (remove blanks, fix capitals, split, merge, change type). Submit the cleaned file and a short report of what you did.
You have a table with “Product”, “Region”, “Sales”, “Quarter”. Use Power Query to: (1) Unpivot the quarters, (2) Group by Region to find total sales, (3) Merge with a product category table (provided) to add category information. This is tricky – try your best!
Fill‑in‑the‑Blank: 1. errors 2. Fill Down 3. Data type 4. Merge 5. Pivot
True or False: 1-F, 2-T, 3-F, 4-F, 5-T
Multiple Choice: 1-b, 2-c, 3-a, 4-b, 5-b, 6-b, 7-b, 8-a, 9-b, 10-b, 11-a, 12-b, 13-a, 14-c, 15-a
In the next module, we will dive into “Data Transformation with M Language”. You will learn how to write simple code to automate all the cleaning steps we did manually. Get ready to become a Power Query wizard!
Note: This is Module Four. In our course, Module Three covers “Connecting to Data Sources”. We will now transition to Module Five, but you have mastered the art of cleaning – well done!