LevelUpWith

Explore / Power Query and Power BI Data Modelling That Adds Up / Lesson 1

Lesson 1: Applied Steps and Query Folding

Learn how Power Query records each change as an applied step that runs again on every refresh, and how query folding sends those steps back to the source so the work happens there.

Free to read, no account needed. Part of Power Query and Power BI Data Modelling That Adds Up.

By the end of this level you'll be able to

  • Read, rename, reorder and delete applied steps in a sample sales query without breaking the steps after them
  • Use the step folding indicators and View Native Query to see which steps fold back to the source
  • Spot a step that stops folding and move it later in the query so the earlier steps still fold

Your query is a recipe

You built a report, it worked, and then a refresh slowed to a crawl or a total came out wrong. Before cleaning any data, you need to know how Power Query does its work.

Power Query does not keep the clicks you make. It writes down steps. Each click adds a line to a script in the M language, and the Applied Steps list (in the Query Settings pane, which you reopen with View > Query Settings) shows that script as a list of steps. On every refresh Power Query runs the whole recipe again from the top, against whatever data is in the source that day. That's why the order of the steps and the way you edit them matter.

(Checked against Microsoft Learn's Power Query documentation on 20 October 2026. Nothing in this lesson is a preview feature.)

The sample: a sales query against SQL Server

You connect Power BI Desktop to a SQL Server table dbo.Sales (about 2 million rows: OrderID, OrderDate, CustomerName, Region, Amount). After a few clicks, Home > Advanced Editor shows this:

let
    // Source: connect to the server and database
    Source = Sql.Database("sql01", "SalesDB"),
    // Navigation: pick the table
    Navigation = Source{[Schema = "dbo", Item = "Sales"]}[Data],
    // Tidy names: Proper-case every customer name ("ACME LTD" -> "Acme Ltd")
    #"Capitalized Each Word" = Table.TransformColumns(Navigation, {{"CustomerName", Text.Proper, type text}}),
    // Keep only the columns the report needs
    #"Removed Other Columns" = Table.SelectColumns(#"Capitalized Each Word", {"OrderDate", "CustomerName", "Region", "Amount"}),
    // Keep only the North region
    #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each [Region] = "North")
 in
    #"Filtered Rows"

Each step takes the step before it as its input: Table.SelectRows(#"Removed Other Columns", ...). That chain is the key to editing safely. Names with spaces get wrapped in #"...". That's ordinary M syntax for a quoted name, nothing to worry about.

Editing steps without breaking the chain

Right-click a step to see what you can do with it:

  • Rename: change Filtered Rows to North only. The editor updates every reference to it in the script, so nothing breaks. Use Properties to add a description as well, which shows as a tooltip in Desktop.
  • Delete (or the X next to the step): the next step is pointed at the step before the one you deleted. Delete until end removes the selected step and every step after it.
  • Move before / Move after, or drag and drop: change the order.
  • Insert step after: add a step partway through the query. Power Query asks you to confirm.

Gotcha: deleting or moving a step is safe only if no later step depends on what it made. Suppose an earlier Renamed Columns step turned Cust into CustomerName. Delete it, and Removed Other Columns fails with an error saying the column CustomerName wasn't found. Click the last step after every edit. The preview pane runs the query up to the step you've selected, so a problem shows up straight away.

Query folding: send the work back to the source

When the source is a database, Power Query tries to translate your steps into the database's own language, SQL for SQL Server, and let the database do the work. That's query folding. There are three possible outcomes:

Outcome What happens
Full folding The source runs every step and sends back only the finished rows
Partial folding The source runs the early steps and Power Query runs the rest locally
No folding The source sends everything and Power Query does all the work

Files have no query engine, so a CSV or Excel source never folds. Everything you do to a CSV runs on your machine.

Why it matters: Microsoft's own example of a "last 10 sales" query against a 3.6 million row table took 361 seconds with no folding and 31 seconds when the query folded completely.

Seeing which steps fold

In Power BI Desktop: right-click a step and choose View Native Query. If you can click it, the query up to that step folds, and you can read the SQL. If it's greyed out, something up to that step doesn't fold. Two warnings: a greyed-out option doesn't mean nothing folds, and some connectors (OData, for example) never offer this option even when they do fold.

In Power Query Online (dataflows and the web editors): every step has a query folding indicator beside it, showing Folding, Not folding, Might fold, Opaque or Unknown, and you can right-click a step and choose View query plan. These indicators are not in Power Query Desktop.

Fix it: move the step that stops folding to the end

In our sample, Capitalized Each Word (Text.Proper) never folds. Because it comes straight after Navigation, every step after it runs locally too. All 2 million rows come down the wire and only then get filtered to North.

The fix: right-click Capitalized Each Word and choose Move after until it's the last step (or drag it there):

    #"Removed Other Columns" = Table.SelectColumns(Navigation, {"OrderDate", "CustomerName", "Region", "Amount"}),  // folds
    #"Filtered Rows" = Table.SelectRows(#"Removed Other Columns", each [Region] = "North"),                             // folds
    #"Capitalized Each Word" = Table.TransformColumns(#"Filtered Rows", {{"CustomerName", Text.Proper, type text}})        // local, but now on far fewer rows

Check: right-click Filtered Rows and choose View Native Query. You should see SQL roughly like this:

select [OrderDate], [CustomerName], [Region], [Amount]
from [dbo].[Sales]
where [Region] = 'North'

Right-click Capitalized Each Word: the option is greyed out. That's fine. The heavy lifting has already folded, and Power Query only proper-cases the North rows.

Best practice: put steps that fold (choose columns, filter rows, sort, keep top rows) first, and steps that stop folding last. Moving a step is only safe if the result is the same. Here it is, because filtering on Region doesn't depend on how the customer names are capitalised.

Key takeaways

  • Applied Steps are a recorded recipe in M that runs again from the top on every refresh. Each step takes the step before it as its input.
  • Renaming a step is safe because references update automatically. Deleting or moving a step can break later steps that depend on its columns, so check the last step after every edit.
  • Query folding sends your steps to the source as its own query. Databases can fold; CSV and Excel files can't.
  • In Desktop, use View Native Query. In Power Query Online, use the folding indicators and the query plan.
  • Steps after one that stops folding usually run locally too. Do the steps that fold first and push steps like Capitalize Each Word to the end.

A 6-question knowledge check follows this lesson in the app, free and without an account.

More like this

  • Microsoft Fabric for Power BI Analysts

    Build a complete sales solution in a Fabric trial workspace, taking raw files through a lakehouse, a warehouse, Dataflows Gen2, pipelines and notebooks to a Di…

    Course · Microsoft · Data & Analytics · Capable · 20 levels · 4 free · Professionally curated by levelupwith.com

  • Power BI from Zero: Build, Publish and Share a Report

    Start from Excel and build one complete Power BI report from a small sample sales dataset. You will connect and clean the data, build a star-shaped model, writ…

    Course · Microsoft · Data & Analytics · Capable · 18 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure Fundamentals (AZ-900) Exam Prep

    Learn to pick the cloud model, service type or Azure service that fits a scenario and explain why the alternatives do not, across every skill in the 20 July 20…

    Exam prep · AZ-900 · Cloud & Compute · Capable · 17 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft Azure Administrator (AZ-104) Exam Prep

    Work through every bullet of the AZ-104 skills measured as of April 17, 2026, learning each task in the Azure portal, Azure CLI, PowerShell, and ARM templates…

    Exam prep · AZ-104 · Cloud & Compute · Expert · 60 levels · 4 free · Professionally curated by levelupwith.com

  • Support Pro: Helping Users Move to Microsoft 365

    Help users get through a move from Google Workspace to Microsoft 365, from the week before cutover to the first tickets afterwards. You will learn what moves a…

    Course · Microsoft · Suite Support Pro: Configure and Fix · Expert · 40 levels · 4 free · Professionally curated by levelupwith.com

  • Microsoft 365 Support Pro: Copilot for End Users

    Learn to work out which Copilot a user actually has, and to fix the everyday Copilot tickets: missing buttons, licence and sign-in problems, files Copilot can'…

    Course · Microsoft · Suite Support Pro: Configure and Fix · Expert · 36 levels · 4 free · Professionally curated by levelupwith.com