Expert Excel · Interactive lesson 3 of 12

Power Query engineering

A6 combined two files into one clean table. Engineering a query means the same recipe survives a file with a missing column, a folder with a rejected row, and a request to run against a different starting path — without you rewriting it from scratch.

ExpertInteractive

Screens shown: Excel for Microsoft 365 for Windows. Practice works in any browser.

Written tutorialPower Query Engineering: Parameters, Staging and Refresh

Skill check

Try these first:

  • Turn a hard-coded file path into a query parameter.
  • Explain what a custom function buys you over repeating the same steps in five queries.
  • Route rows that fail a type conversion into a separate error table instead of silently dropping them.
  • Explain the difference between a staging query and one that loads to the workbook.

All familiar? Skip ahead to E4 — Data Model & DAX.

Concept teach

What you're learning

Query parameters
A named, editable value (a folder path, a year, a threshold) referenced throughout a query — change it once in one place instead of hunting through every step.
Custom functions
A query written once and invoked with different inputs — the same idea as a LAMBDA, built for M instead of formulas, so five near-identical import queries become one function called five times.
Folder ingestion patterns
Point at a folder, not a file — every file inside combines automatically, including ones added after the query was built, as long as they match the expected shape.
Error rows & exception handling
A row that fails a type conversion doesn't have to vanish — route it to a separate "Rejected Rows" query so someone can see and fix what didn't load, instead of a silently short count.
Staging queries
An intermediate query set to "Connection only" — it does real work (cleaning, typing) but never loads to a sheet itself; other queries reference it instead of repeating its steps.
Load destinations
Load to a Table, to the Data Model, or Connection Only — the same imported data serves three completely different jobs depending on where it lands.
Refresh diagnostics
When a refresh is slow or wrong, check row counts before and after, look for a step that reads more than it needs to, and confirm every source file actually matched the expected pattern.
M code readability
Rename each Applied Step to say what it does ("Remove Cancelled Orders," not "Filtered Rows1") — the step list is documentation whether you write it that way or not.

Where to find it in Excel

Data›Get Data›Launch Power Query Editor

Swipe sideways to see the whole window.

  1. 1Data › Get Data.
  2. 2Launch Power Query Editor: Home › Manage Parameters, Advanced Editor for M code, Close & Load To for destinations.
  3. 3A parameter holds the folder path so the query survives a move.
  4. 4Staging queries load as Connection only.
  5. 5Bad rows go to their own table instead of disappearing.

Rendered view of Excel for Microsoft 365 (Windows). Ribbon layout can differ slightly on Mac, Excel for the web or a narrow window.

Guided build

A folder of monthly exports, driven by a parameter — and one file with a bad row. Work through the engineered version of the import.

🔌 Engineered Query — parameter-driven, with a staging step
Every step below reads this parameter — change it and every query re-points at once.
Start with staging — combine the folder and set real types before anything else touches the data.

Independent extension

Engineer a real folder import

Turn a repeated import into a parameterized query: replace the hard-coded path with a parameter, split the work into a Connection-Only staging query plus a query that loads it, and route any row that fails a type conversion into a visible "Rejected Rows" table instead of letting it vanish.

Spot a mistake or have an idea for this lesson? Send feedback