Courses Learn Blog Contact
Get Started →
Lesson 5

Day 4 Lab: Cleaning Sales_2023 Together

The whole cleaning query built as a class, the mistakes everybody makes, and how to find them.

Webbo3 Power BI Cohort 1 8 min read Free

Webbo3 Power BI · Cohort 1 · Day 4 of 16 · Lab

Day 4 Lab: Cleaning Sales_2023 Together

One query, built as a class from the raw sheet to the clean table, with a checkpoint after every step.

By the end of today you can

  • Build the complete Sales_2023 cleaning query without notes
  • Check your work step by step against row counts and distinct counts
  • Recognise the seven mistakes this class makes most, from their symptoms
  • Read Applied Steps to find which step went wrong
  • Start Assignment 1 knowing exactly what is expected

A lab day is a working day. Your tutor drives on the projector, you build the same query on your own laptop, and the class stops at every checkpoint until every laptop agrees.

Start from nothing: a new Power BI file, Get Data, Excel workbook, the Webbo Oil workbook, tick Sales_2023 only, Transform Data. Delete Power BI's Changed Type step. By the end, your Applied Steps will match the checkpoint table below exactly.

1. How the Lab Works

Definition

A checkpoint is a number you can see on your own screen that proves a step worked: the row count at the bottom left of the preview, or the distinct count in Column profile. If your number differs from the class number, you stop and fix it before the next step, because every later step builds on this one.

Real-Life Example

A driving instructor who checks your mirrors before you move, your signal before you turn, and your speed before the bend. Catching a mistake at the step it happens is easy. Finding it three steps later is not.

Types: The Three Numbers to Watch

NumberWhere you see itWhat it proves
Row countBottom left of the preview: "9 COLUMNS, 3,189 ROWS"Rows were (or were not) removed
Distinct countColumn profile pane, with profiling on the entire data setSpellings were (or were not) merged
Column qualityUnder each header: Valid, Error, EmptyTypes converted with no errors
Before You Start

View tab: tick Column quality, Column distribution and Column profile. Bottom of the window: switch profiling to "based on entire data set". Without this the counts are for the first 1,000 rows only and will not match the class.

2. The Build, With Checkpoints

What we are checkingWe want the checkpoint for every step: the rows left, how many different station, product and payment values remain, and how many attendant cells are still empty. Stop after each step until your screen shows the same.
Class checkpoints, Sales_2023
After this stepRowsStationsProductsPaymentsEmpty attendants
Navigation (Sales_2023) + Promoted Headers3,18927117224320
Changed Type with Locale3,18927117224320
Trimmed Text3,18921158320
Capitalized Each Word3,189753320
Replaced Values (GRA, PMS, AGO, DPK, POS)3,189753320
Replaced Value (null to Unmanned)3,1897530
Filtered Rows (Date is not blank)3,1817530
Removed Duplicates3,1347530
Filtered Rows (Quantity > 0)3,1167530

Step by Step

The class build

1.Applied Steps: delete "Changed Type"
2.Date header › Change Type › Using Locale › Date › English (United Kingdom)
3.Quantity, UnitPrice_NGN, TotalAmount_NGN: Decimal Number
4.StationName, ProductName, AttendantName, PaymentMethod › Transform › Format › Trim
5.Same four columns › Format › Capitalize Each Word
6.Replace Values x5: GRA, PMS, AGO, DPK, POS (Match entire cell contents)
7.AttendantName › Replace Values › null › Unmanned
8.Date dropdown › Untick (null)
9.Ctrl+A to select every column › Home › Remove Rows › Remove Duplicates
10.Quantity dropdown › Number Filters › Greater Than › 0

Reading Applied Steps

Applied Steps is the history of your query. Click any step and the preview shows the data exactly as it was at that moment, with its row count at the bottom. That is how you find a mistake: click down the steps one at a time and watch for the first number that differs from the class.

Try This

Click the first step, then each step below it, and write down the row count each time. Your list should match the Rows column above, number for number.

Picture This

Picture the driving instructor: mirrors, signal, speed, one at a time, before you move on.

3. Fixing Mistakes as a Class

Definition

A symptom is the wrong number you notice; the cause is the step that made it. The skill today is working backwards from one to the other. Each mistake below was made on the real sheet, and the symptom shown is exactly what you would see.

Real-Life Example

A doctor does not start with "which organ is broken?" She starts with "where does it hurt?" and works back. A row count that is too high is where it hurts.

Types: The Seven Mistakes

Symptom on your screenCauseFix
StationName shows 21 values, not 7Capitalize Each Word was skippedAdd it straight after Trim
StationName shows 7 values, but one is "Gra Filling Station"The five Replace Values steps were skippedAdd them after Capitalize Each Word. On Day 5 "Gra" would match nothing in Station_Master
Only 2,608 rows after the Date stepDate typed with English (United States), then "Remove Errors" used to hide the errorsDelete both steps; Change Type, Using Locale, English (United Kingdom)
Only 7 rows after Remove DuplicatesOnly StationName was selected when you clicked Remove DuplicatesDelete the step; Ctrl+A to select every column; do it again
3,163 rows at the end, not 3,116Remove Duplicates was skippedAdd it before the Quantity filter
3,124 rows at the endThe blank dates were keptDate dropdown, untick (null)
320 empty attendant cells at the endnull was not replaced with UnmannedAttendantName, Replace Values, null, Unmanned
What we are checkingWe want to see how much each row mistake would move Webbo Oil's 2023 revenue, so it is clear why the checkpoints matter.
Revenue, 2023
Version of the queryRowsRevenue
Correct3,116₦57,056,529
Duplicates kept3,163₦57,664,896
Refunds (zero or negative quantities) kept3,134₦56,782,141
Blank dates kept3,124₦57,299,293

Keeping the duplicates overstates revenue by ₦608,367. That is money the business never received, reported as if it had.

Never Use "Remove Errors" to Make Errors Go Away

Remove Errors deletes whole rows. On a Date column read with the wrong locale it deletes 581 real sales, and the rows it keeps still include 326 dates with day and month swapped. An error is information: find out why it happened.

Unmanned Is Not a Mistake to Remove

312 clean 2023 sales, ₦5,745,847 of revenue, came from unmanned pumps. Delete those rows and every station looks poorer than it is.

Picture This

Picture the doctor: start with where it hurts (the number), work back to the cause (the step).

4. Assignment 1 Is Released

You have now built the query live. Assignment 1 asks you to do the same to Sales_2024, alone, by Day 6. The sheet has the same columns and the same kinds of mess, and different rows.

Read the Brief Tonight

The full brief, the hand-in and the marking are on the Assignment 1 page. It is the next lesson in this course.

Do This Now

  1. Build the query from the first step to the Quantity filter, stopping at every checkpoint.
  2. Click down Applied Steps and check each row count against the table.
  3. Break it on purpose: delete the five Replace Values steps and read the StationName values. Undo it.
  4. Rename the query Sales_2023_Clean and save your .pbix.
  5. Read the Assignment 1 brief.

Checkpoint

Q1. Your final row count is 3,163. Which step is missing?

Remove Duplicates. The zero and negative quantities are gone, but the rows submitted twice are not.

Q2. Your stations look right but one reads "Gra Filling Station". Does it matter?

Yes. On Day 5 you merge on StationName, and "Gra" matches nothing in Station_Master, so every GRA sale loses its city and region.

Q3. Why not just use Remove Errors on the Date column?

It deletes real sales and hides the actual problem, the locale. Fix the locale and there are no errors to remove.

Q4. Why replace empty attendants instead of filtering them out?

They are real sales from unmanned pumps. Removing them would understate revenue.

Tick Before You Move On

  • ☐ My Applied Steps match the class checkpoints, step by step
  • ☐ I finish with 3,116 rows, 7 stations, 5 products and 3 payment methods
  • ☐ There are no empty attendant cells: they say Unmanned
  • ☐ I can name the cause of each of the seven symptoms
  • ☐ I have read the Assignment 1 brief

Quick Recap

Check a number after every step: row count, distinct count, column quality. Symptom first, then cause: a wrong count points at one step. Remove Errors hides problems and deletes real rows. Capitalize Each Word needs the five abbreviation fixes after it. Assignment 1 is the same recipe on Sales_2024, alone.

Final Scenario

At the end of the lab a classmate's total is higher than everyone else's. She is sure her query is right, because it has no errors.

You ask for her row count. It is 3,163. In ten seconds you both know Remove Duplicates is missing, and that her report would have shown Webbo Oil ₦608,367 richer than it is.

No errors is not the same as right. Checkpoints are how you know.

Next: the Assignment 1 brief, then Day 5, appending and merging queries.

Learn this with a real instructor

Free lessons take you a long way on your own. The full programmes add live classes, assignments, Skill Points and a certificate — built for African students.