Welcome back, young data explorer! Today we learn how to clean and shape our data.
In Module One, you learned what Power BI is and how to create simple reports. But here is a secret: data is not always clean. Sometimes it has mistakes, missing values, or is in the wrong format. That is where Power Query comes in.
Imagine you are baking a cake. You need to wash and prepare the ingredients before you start. Data is the same. You need to clean and prepare it before you can make beautiful charts.
Power Query is the tool that helps you clean and prepare your data. It is like a magic kitchen where you chop, mix, and prepare your data ingredients.
In this module, you will learn about the Power Query Editor, the M language, and how to clean, shape, and transform your data. By the end, you will be able to turn messy data into clean, analysis-ready data.
๐ก Think about it: Have you ever had a messy room and needed to clean it? Data is the same โ you need to clean it before you can use it.
By the time you finish this module, you will be able to:
Nneka is a 12-year-old girl who loves to collect data. She asked her classmates about their favourite foods and wrote down their answers. But her notebook was messy. Some names were spelled wrong. Some answers were missing. Some were written in different ways.
Nneka tried to make a chart, but it was hard. She showed her notebook to her uncle, who works with data. Her uncle said, "Nneka, your data is messy. You need to clean it before you can make a chart."
He opened Power BI and showed her the Power Query Editor. Together, they fixed the misspelled names, filled in missing answers, and made everything consistent. Then they created a beautiful chart showing the favourite foods of the class.
Nneka learned that cleaning data is just as important as making charts. Without clean data, your charts can be wrong.
๐ง Think about it: Have you ever had data that was messy or hard to understand? What did you do?
Definition: Power Query is a tool in Power BI that helps you clean, shape, and transform your data before you use it in reports.
Why it is important: Real-world data is often messy. Power Query helps you fix it so your reports are accurate.
Simple explanation: Think of Power Query like a car wash for your data. It cleans off the dirt and makes your data shiny and ready to use.
๐ซ School example: A teacher uses Power Query to clean student data before creating a report.
๐ Home example: Your parents use Power Query to clean their expense data before making a budget.
๐ณ๐ฌ Nigerian example: A Nigerian business uses Power Query to clean sales data from different stores.
Illustration:
+-------------------+
| MESSY DATA | โ Data with errors, blanks, and mistakes
+-------------------+
|
V
+-------------------+
| POWER QUERY | โ The cleaning tool
+-------------------+
|
V
+-------------------+
| CLEAN DATA | โ Ready for analysis
+-------------------+
๐ Mini summary: Power Query is a tool that cleans and shapes your data.
Definition: The Power Query Editor is the window where you clean and transform your data. It shows you a preview of your data and the steps you are applying.
Why it is important: The Power Query Editor gives you full control over how your data is transformed.
Simple explanation: Think of the Power Query Editor like a kitchen. You can see all your ingredients and decide what to do with them.
๐ซ School example: A teacher uses the Power Query Editor to preview student data before cleaning it.
๐ Home example: Your parents use the Power Query Editor to see their expense data.
๐ณ๐ฌ Nigerian example: A business analyst uses the Power Query Editor to preview sales data.
๐ Mini summary: The Power Query Editor is where you clean and transform your data.
Definition: M is the language that Power Query uses to perform transformations. Every time you click a button in Power Query, it writes M code behind the scenes.
Why it is important: Understanding M helps you create more powerful transformations.
Simple explanation: Think of M like the recipe for your data. It tells Power Query exactly what to do.
๐ซ School example: A teacher uses the M language to clean student data in a repeatable way.
๐ Home example: Your parents use M to clean expense data every month.
๐ณ๐ฌ Nigerian example: A business uses M to clean sales data from multiple sources.
๐ Mini summary: M is the language Power Query uses to transform data.
Definition: To start cleaning your data, you need to open the Power Query Editor.
Why it is important: You can't clean your data without opening the editor.
Simple explanation: Think of it like opening a toolbox to fix something.
๐ซ School example: A teacher opens the Power Query Editor to clean student data.
๐ Home example: Your parents open the Power Query Editor to clean expense data.
๐ณ๐ฌ Nigerian example: A business analyst opens the Power Query Editor to clean sales data.
๐ Mini summary: The Power Query Editor is opened by clicking "Transform Data".
Definition: Removing duplicates means deleting rows that are exactly the same.
Why it is important: Duplicates can make your data inaccurate and cause you to count things twice.
Simple explanation: Imagine you have a list of students and one student is listed twice. You would delete the duplicate so you don't count them twice.
๐ซ School example: A teacher removes duplicate student names from a list.
๐ Home example: Your parents remove duplicate expense entries.
๐ณ๐ฌ Nigerian example: A business removes duplicate customer records.
๐ Mini summary: Removing duplicates helps keep your data accurate.
Definition: Filtering rows means keeping only the rows that meet certain conditions.
Why it is important: Filtering helps you focus on the data that matters.
Simple explanation: Imagine you have a list of all students, but you only want to see those in Grade 5. You would filter the list to show only Grade 5 students.
๐ซ School example: A teacher filters student data to show only Grade 5 students.
๐ Home example: Your parents filter expenses to show only food expenses.
๐ณ๐ฌ Nigerian example: A business filters sales data to show only Lagos sales.
๐ Mini summary: Filtering helps you focus on the data that matters.
Definition: A null is a blank or missing value in your data. Handling nulls means deciding what to do with them.
Why it is important: Nulls can cause errors in your reports.
Simple explanation: Imagine you have a list of students, but one student's grade is missing. You need to decide what to do โ fill in a grade, or remove that student.
๐ซ School example: A teacher replaces null grades with 0.
๐ Home example: Your parents replace null expense amounts with 0.
๐ณ๐ฌ Nigerian example: A business replaces null sales amounts with 0.
๐ Mini summary: Handling nulls prevents errors in your reports.
Definition: Pivoting turns rows into columns. Unpivoting turns columns into rows.
Why it is important: Sometimes your data is in the wrong shape for analysis. Pivoting and unpivoting fix that.
Simple explanation: Imagine you have a table with sales for each month in columns. You might want to have a single column for months and another for sales. That is unpivoting.
๐ซ School example: A teacher unpivots a table of grades by subject.
๐ Home example: Your parents unpivot a table of monthly expenses.
๐ณ๐ฌ Nigerian example: A business unpivots sales data by quarter.
๐ Mini summary: Pivoting and unpivoting change the shape of your data.
Definition: Merging combines two tables based on a common column. Appending stacks two tables on top of each other.
Why it is important: Sometimes your data is in multiple tables. Merging and appending help you combine them.
Simple explanation: Imagine you have a list of students and a list of grades. You merge them to have one table with students and their grades.
๐ซ School example: A teacher merges student data with grade data.
๐ Home example: Your parents merge expense data from different sources.
๐ณ๐ฌ Nigerian example: A business merges sales data with customer data.
๐ Mini summary: Merging and appending help you combine data from multiple sources.
Definition: Applied steps are the list of transformations you have applied to your data. You can see them on the right side of the Power Query Editor.
Why it is important: Applied steps help you track what you have done and make changes if needed.
Simple explanation: Think of applied steps like a recipe log. It shows each step you took to cook your data.
๐ซ School example: A teacher renames steps to "Remove Duplicates" and "Filter Grade 5".
๐ Home example: Your parents rename steps to "Clean Expenses" and "Remove Nulls".
๐ณ๐ฌ Nigerian example: A business renames steps to "Merge Sales" and "Filter Lagos".
๐ Mini summary: Applied steps help you track your transformations.
| Word | Simple Meaning |
|---|---|
| Power Query | A tool for cleaning and shaping data. |
| Power Query Editor | The window where you clean and transform data. |
| M Language | The language used by Power Query. |
| Data Transformation | Changing data to make it ready for analysis. |
| Data Cleaning | Removing errors and fixing mistakes in data. |
| Data Shaping | Changing the structure of data. |
| Duplicate | A row that appears more than once. |
| Filter | Keeping only certain rows. |
| Null | A blank or missing value. |
| Pivot | Turning rows into columns. |
| Unpivot | Turning columns into rows. |
| Merge | Combining two tables based on a common column. |
| Append | Stacking two tables on top of each other. |
| Applied Steps | The list of transformations applied. |
| M Code | The code written in the M language. |
+-------------------+
| MESSY DATA | โ Data with errors, blanks, and mistakes
+-------------------+
|
V
+-------------------+
| REMOVE DUPLICATES | โ Delete duplicate rows
+-------------------+
|
V
+-------------------+
| FILTER ROWS | โ Keep only what you need
+-------------------+
|
V
+-------------------+
| HANDLE NULLS | โ Fill or remove blanks
+-------------------+
|
V
+-------------------+
| CLEAN DATA | โ Ready for analysis
+-------------------+
+-------------------+
| BEFORE | โ Region | Q1 | Q2 | Q3 | Q4
+-------------------+
|
V
+-------------------+
| UNPIVOT | โ Region | Quarter | Sales
+-------------------+
+-------------------+
| MERGE | โ Combine tables side by side
+-------------------+
|
+-------------------+
| APPEND | โ Stack tables on top of each other
+-------------------+
| Dirty Data | Clean Data |
|---|---|
| Duplicates | No duplicates |
| Missing values | No missing values |
| Errors | No errors |
| Inconsistent formatting | Consistent formatting |
| Hard to analyse | Easy to analyse |
Lesson 1: Power Query is a tool for cleaning and shaping data.
Lesson 2: The Power Query Editor is where you clean and transform data.
Lesson 3: M is the language of Power Query.
Lesson 4: Open the Power Query Editor by clicking "Transform Data".
Lesson 5: Removing duplicates keeps data accurate.
Lesson 6: Filtering helps you focus on what matters.
Lesson 7: Handling nulls prevents errors.
Lesson 8: Pivoting and unpivoting change data shape.
Lesson 9: Merging and appending combine data.
Lesson 10: Applied steps help you track transformations.
In this module, you learned about Power Query โ the tool for cleaning and shaping data. You discovered the Power Query Editor, the M language, and how to clean data by removing duplicates, filtering, and handling nulls. You also learned how to shape data by pivoting, unpivoting, merging, and appending.
๐ฏ You can now:
Match the word on the left with the correct meaning on the right:
| Word | Meaning |
|---|---|
| Power Query | The language of Power Query |
| M Language | A tool for cleaning data |
| Duplicate | A row that appears more than once |
| Null | A blank or missing value |
Answers: Power Query โ A tool for cleaning data; M Language โ The language of Power Query; Duplicate โ A row that appears more than once; Null โ A blank or missing value.
Scenario 1: Nneka has a list of students with their grades. Some students are listed twice, and some grades are missing. What should Nneka do? How can Power Query help her?
Scenario 2: A Lagos supermarket has sales data in different tables. They want to combine the data to see total sales by product. How can Power Query help them?
In groups of 4โ5, discuss a type of messy data you have encountered. Think about how you could use Power Query to clean it. Present your ideas to the class.
Think about a dataset you could clean. Write a short paragraph (about 100 words) about how you would use Power Query to clean it.
Clean a Dataset
Find a messy dataset (e.g., a list of sales with duplicates and missing values). Use Power Query to clean it. Document the steps you took and the final result.
Download a sample dataset with errors. Use Power Query to clean it by removing duplicates, handling nulls, and filtering. Write a short report (about 150 words) about what you did and what you learned.
The Challenge: Imagine you are a business analyst in Lagos. You have sales data from four different stores, each in a different format. Use Power Query to clean and combine the data. Create a single table with all sales data.
Multiple Choice: 1-A, 2-A, 3-A, 4-A, 5-A, 6-A, 7-A, 8-A, 9-A, 10-A, 11-D, 12-A, 13-A, 14-A, 15-A
Fill-in-the-Blank: 1. cleaning, 2. M, 3. duplicates, 4. matters, 5. Nulls
True or False: 1. False, 2. True, 3. True, 4. False, 5. True
Matching: Power Query โ A tool for cleaning data; M Language โ The language of Power Query; Duplicate โ A row that appears more than once; Null โ A blank or missing value.
In the next module, we will explore Data Modeling and Relationships. You will learn how to build robust data models and create relationships between tables. Before then, try to think about how different tables of data can be connected.
๐ Congratulations! You have completed Module Two of the Power BI for Data Analysis Expert course.
๐ You are now ready to move to Module Three: Data Modeling and Relationships.