← Back to all projects Excel · Power Query · Data cleaning

Cleaning Messy Cafe Data

A cafe sales file full of "ERROR", "UNKNOWN" and blanks. I fixed it logically, recovering values instead of deleting rows.

ToolsExcel · Power Query
Data10,000 transactions
Method8 cleaning steps
Rows deleted0
The problem

Data you can't calculate with

❌

"ERROR" values

Text sitting inside number columns, so totals and averages break.

❓

"UNKNOWN" values

A placeholder pretending to be data in item, payment and location columns.

⬜

Blank cells

Missing items, quantities, prices and totals.

See it

Before and after

Real rows from the file. Switch between the messy and cleaned versions.

TransactionItemQtyPriceTotalPaymentLocation
TXN_4271903Cookie41ERRORCredit CardIn-store
TXN_7034554Salad2510UNKNOWNUNKNOWN
TXN_4433211UNKNOWN339ERRORTakeaway
TXN_8915701ERROR21.53(blank)In-store
TXN_3522028SmoothieERROR420CashIn-store

Why "Cake/Juice"? Both cost $3, so the price alone can't tell them apart. I labelled it honestly instead of guessing.

Walkthrough

8 steps in Power Query

The order matters: first standardise what "missing" means, then recover values with simple logic.

Replace "UNKNOWN" with blanks

Done across all columns.

Why: UNKNOWN isn't real data, so it's treated as missing.

Replace "ERROR" with blanks

Error values can't be used in calculations.

Why: they have to be cleaned before anything else.

Convert empty text to real blanks

Empty strings become true null values.

Why: missing values are now consistent everywhere.

Fix data types

Numbers stored as text become numbers.

Why: so calculations actually work.

Fill missing price

Price = Total ÷ Quantity, or the item's standard price.

Why: recovers values intelligently.

Calculate missing total

Total = Quantity × Price.

Why: basic maths restores the missing totals.

Recover missing item from price

Each item has a typical price, so price points to the item.

Why: where two items share a price, the label shows both (for example Cake/Juice).

Calculate missing quantity

Quantity = Total ÷ Price.

Why: the final step that completes the dataset.

Clean→ Standardise→ Recalculate→ Recover No rows deleted. Everything fixed logically.
Results

Column quality: before vs after

Reduction in problem cells per column.

Items333 → 6 · 98.2% fewer issues
Quantity479 → 23 · 95.2% fewer issues
Price per unit533 → 6 · 98.9% fewer issues
Total spent502 → 23 · 95.4% fewer issues

Where the problems were

ColumnBlankUnknownError
Quantity138171170
Price per unit179164190
Total spent173165164

Because quantity, price and total depend on each other, one known value can often rebuild another.