Welcome to Module 4!
In the previous module, you learned how to connect Power BI to Excel files, CSV files, and databases. You also learned how to import information into Power BI.
But what happens when the information you import contains mistakes?
Imagine a school in Ibadan gives you an Excel file containing the examination results of 500 students. When you open the file, you discover some problems:
If you create a report using incorrect information, your results may also be incorrect.
This is why you need to clean and prepare your data before analysing it.
Power Query is a data preparation tool available in Power BI and other Microsoft products.
It helps you collect, clean, organise, and transform information before using it for analysis.
Think of Power Query as a cleaning room for your data.
Imagine you buy vegetables from a market. Before cooking them, you wash them, remove unwanted parts, and arrange them properly.
Power Query does something similar with information. It helps remove unwanted records, correct mistakes, and arrange data properly.
Imagine you import this student information into Power BI:
| Student Name | Score | Class |
|---|---|---|
| David | 85 | JSS 2 |
| Mary | 92 | JSS 2 |
| David | 85 | JSS 2 |
| John | (Blank) | JSS 2 |
There are two problems:
Power Query can help you identify and handle these problems.
The Power Query Editor is the workspace where you clean and transform your data.
To open it:
Inside Power Query Editor, you will find different sections.
The Ribbon contains commands for cleaning, transforming, and managing data.
The Queries pane displays the tables or data sources you have opened in Power Query.
This area displays your information in rows and columns so you can inspect it before loading it into Power BI.
The Query Settings pane displays the properties of your query and the steps you have performed.
Applied Steps is a list of the changes you have made to your data.
For example, if you remove duplicates and rename a column, Power Query records these actions as steps.
A duplicate record is information that appears more than once when it should appear only once.
Imagine a school has a student register. David's name appears twice even though he is only one student.
This can cause problems when calculating the number of students in the school.
| Student | Score |
|---|---|
| David | 85 |
| Mary | 92 |
| David | 85 |
| John | 70 |
David's record appears twice.
Important: Be careful when choosing columns. If you select only Student Name, Power Query may remove records where the same student has different examination results. For examination records, you may need to select several columns or use a unique student ID to identify true duplicates.
Sometimes, a data file contains empty spaces where information should be.
These are called missing values or blank values.
For example, a student may have a name and class but no examination score.
| Student | Score |
|---|---|
| David | 85 |
| Mary | 92 |
| John | (Blank) |
John's score is missing. What should you do?
You have different options depending on why the information is missing.
If the record is not needed and removing it will not affect your analysis, you may remove the row.
If you have a reliable source for the missing information, you can enter the correct value.
Sometimes, it is better to leave a value blank rather than guess. For example, you should not invent a student's examination score.
Always check why information is missing before removing it.
Every column in a dataset should have an appropriate data type.
A data type tells Power BI what kind of information is stored in a column.
For example:
| Data Type | Meaning | Example |
|---|---|---|
| Text | Letters and words. | David |
| Whole Number | Numbers without decimal places. | 25 |
| Decimal Number | Numbers with decimal places. | 25.75 |
| Date | Calendar dates. | 26/11/2026 |
| Date/Time | A date and time together. | 26/11/2026 10:30 AM |
| True/False | A value that is either true or false. | True |
Example: If a Score column contains 85, 90, and 75 but is recognised as Text, change it to Whole Number so it can be used correctly in calculations.
Sometimes, columns have names that are difficult to understand.
Imagine you import a file with these column names:
These names do not tell you what the information means.
You can rename them to:
Clear column names make your data easier to understand.
Power Query allows you to split one column into multiple columns or combine information from different columns.
Splitting means dividing information in one column into separate columns.
Imagine a school has a column containing students' full names.
| Full Name |
|---|
| David Johnson |
| Mary James |
| John Peter |
You may want to separate the first name from the surname.
After splitting, your table may look like this:
| First Name | Surname |
|---|---|
| David | Johnson |
| Mary | James |
| John | Peter |
Merging means combining information from two or more columns into one column.
For example, imagine you have:
| First Name | Surname |
|---|---|
| David | Johnson |
| Mary | James |
You can combine the two columns to create a Full Name column.
Filtering and sorting help you organise information so you can find what you need.
Filtering means displaying only the records that match certain conditions.
Imagine a school has students in JSS 1, JSS 2, and JSS 3. You want to see only the JSS 2 students.
You can use a filter to display only records where Class equals JSS 2.
Sorting means arranging information in a particular order.
For example, you can arrange students' scores from the highest to the lowest.
There are two common sorting orders:
After cleaning and preparing your data, you need to send the changes back to Power BI Desktop.
To do this:
Power Query keeps a record of the transformation steps. When you refresh your data, Power BI can run those steps again on the updated source data.
Imagine a school in Ibadan gives you the following records. Your job is to clean the information using Power Query.
| Student Name | Class | Score |
|---|---|---|
| David | JSS 2 | 85 |
| Mary | JSS 2 | 92 |
| David | JSS 2 | 85 |
| John | JSS 2 | (Blank) |
| Sarah | JSS 3 | 78 |
Your tasks:
Challenge Questions:
| Term | Simple Meaning |
|---|---|
| Power Query | A tool for collecting, cleaning, and transforming data. |
| Power Query Editor | The workspace where you prepare your data. |
| Duplicate | A record or value that appears more than once. |
| Missing Value | Information that is empty or unavailable. |
| Data Type | The kind of information stored in a column. |
| Filtering | Displaying only records that match selected conditions. |
| Sorting | Arranging information in a particular order. |
| Transformation | Changing data into a more useful format. |
| Applied Steps | A record of the changes made to a query. |
| Close & Apply | Applies the transformations and returns to Power BI Desktop. |
Choose the correct answer for each question.
In this module, you learned how to clean and prepare information using Power Query. You discovered how to remove duplicates, handle missing values, change data types, rename columns, split and merge information, and filter and sort records.
You also learned how to apply your changes using Close & Apply.
Remember, good data preparation helps you create more accurate and useful reports.
Creating Charts and Data Visualisations: You will learn how to turn your prepared data into bar charts, column charts, line charts, pie charts, tables, cards, and maps. You will also discover how to choose the right chart for different types of information.