Day 2 — Power Query — getting data in and cleaning it
The step that happens before any measure runs. Get it right and everything downstream is easier.
What Power Query is for
Power Query is the loading dock. Data arrives messy, and Power Query fixes it once, at refresh time, before the model ever sees it. Every fix you make is recorded as a step, and those steps replay automatically next month on next month’s file.
The Applied Steps list
Everything you click is written down on the right of the Power Query window, in order:
You can click any step to see the table as it was at that moment, reorder them, or delete one. This is version control for your cleaning, and it is why Power Query beats doing the same work by hand in Excel.
The steps worth knowing on day one
| Step | What it fixes |
|---|---|
| Promote Headers | The first row is really the column names |
| Change Type | Dates loaded as text, numbers loaded as text |
| Remove Columns | The 40 columns nobody asked for |
| Filter Rows | Cancelled orders, test records, blank rows |
| Replace Values | "N/A" where a number should be |
| Trim / Clean | Stray spaces that break relationships |
| Split Column | "DL-2024-0912" into three usable fields |
| Group By | Collapsing detail you do not need |
Change Type is the one that bites
The same applies to numbers. A column of amounts loaded as text sums to nothing at all, silently.
Remove columns early, and be ruthless
Every column you keep costs memory and refresh time. A common source export has sixty columns; a report usually needs eight.
Filter rows early too
If the report only covers the last two financial years, filter to that in Power Query rather than loading eleven years and filtering in a visual. The rule is the same: the earlier you throw data away, the faster everything downstream becomes.
Why not just do it in DAX?
You often can. You usually should not.
| Job | Where it belongs | Why |
|---|---|---|
| Removing columns | Power Query | Runs once at refresh |
| Fixing data types | Power Query | The model needs them right |
| Splitting a code into parts | Power Query | Stored once, not recomputed |
| Combining two files | Power Query | Append and Merge exist for this |
| Total sales | DAX measure | Must react to slicers |
| % of total | DAX measure | Depends on what is filtered |
| Year-on-year growth | DAX measure | Depends on the visual |
The dividing line: if the answer changes when someone clicks a slicer, it must be a measure. If it is the same every time, do it in Power Query.
Checking your work
After cleaning, the model here holds 48 sales rows. A quick row count is the cheapest sanity check there is:
Try these yourself
- List the Applied Steps you would use to load a CSV whose first row is the header and whose date column arrives as text.
- Explain why removing a column beats hiding it.
- Decide where "profit margin percentage" belongs — Power Query or DAX — and say why.
- Count the rows in the Calendar table.
- Name the one check you should run after every refresh.
