Query Folding in Power Query: Complete Guide for Faster Data Loading
Learn how Query Folding in Power Query speeds up data refresh by pushing steps back to SQL. Understand what folds, what breaks, and how to optimize.
When I first started working with Power Query in Excel/ Power BI, I kept hearing the term “Query Folding.” It sounded technical and intimidating, but once I got my head around it, it completely changed the way I handle data transformations.
Here’s the big idea: Query Folding is when Power Query translates your M language steps (filters, joins, grouping, etc.) into SQL statements that your database can process directly.

Why does this matter? Because instead of dragging tons of raw data into Power Query and transforming it on your machine, Query Folding pushes those transformations back to the source. That means less data traveling over the wire, faster refresh times, and more efficient queries.
In this guide, I’ll walk you through what Query Folding is, how it works in Power Query, what steps fold vs. what steps break folding, and practical tips to keep your queries running lightning-fast.
What Is Query Folding in Power Query?
At its core, Query Folding is Power Query’s ability to offload work to the SQL database instead of doing it locally.
Think of it like this:
- Without Query Folding → You load all data from SQL into Power Query, then apply transformations in M.
- With Query Folding → Power Query converts your M transformations into SQL (like
SELECT
,WHERE
,GROUP BY
) and only pulls the already-transformed dataset.
This makes your ETL (Extract, Transform, Load) process way more efficient.

Why Query Folding Matters
From my experience, the difference between folding and non-folding can mean the difference between a 30-second refresh and a 30-minute refresh.
Benefits include:
- ⚡ Performance: Only the final SQL query result is sent to Power Query.
- 📉 Efficiency: Less data over the network = faster refreshes.
- 🛠️ Maintainability: SQL-backed transformations are easier to trace.
- 🌍 Scalability: Works better as your data grows.
if your source is SQL, always try to maximize folding before adding custom M steps.
How to Know If Query Folding Is Happening
The easiest way to check is to look at the Native Query option in Power Query.
- Right-click a step in your Applied Steps pane.
- If “View Native Query” is clickable (not greyed out), folding is happening.
- Click it, and you’ll see the exact SQL statement that Power Query is sending to the database.

👉 Pro tip: If you’re building a query for performance, check this early. The moment a step breaks folding, all subsequent steps also stop folding.
Examples of Steps That Fold (SQL-Compatible)
Most SQL-native operations fold without issue. Here are some common examples:
- Filtering rows →
WHERE
- Choosing specific columns →
SELECT
- Sorting rows →
ORDER BY
- Merging tables →
INNER JOIN
,LEFT OUTER JOIN
- Grouping and aggregations →
GROUP BY
- Removing duplicates →
SELECT DISTINCT
Basically, if you can express it in SQL, Power Query will usually fold it.

Examples of Steps That Break Folding
Not every Power Query transformation can be translated into SQL. Once you add one of these, folding stops:
- Custom columns with complex M logic SQL doesn’t support.
- Text functions like
Text.Proper
or advanced string manipulation. - Index columns or column reordering.
- Custom functions or non-native M expressions.
- Merging with non-database sources (e.g., combining SQL with Excel).
Once folding is broken, all subsequent transformations happen locally in Power Query — which can be painfully slow with large datasets.

Best Practices for Maintaining Query Folding
Based on trial and error, here are my top tips:
- Do SQL-friendly steps first. Apply filters, column selections, joins, and aggregations before adding custom M logic.
- Check Native Query often. Don’t wait until the end to realize folding broke ten steps ago.
- Use custom SQL only when necessary. Sometimes writing a SQL view or stored procedure upfront gives you more control.
- Push heavy logic upstream. If SQL can do it, let SQL do it.
- Document broken folding points. This makes it easier to optimize later.
My Verdict: Is Query Folding Worth Learning?
Absolutely. If you’re working with SQL sources in Power Query, understanding Query Folding is a must-have skill.
I’ve seen refresh times drop from hours to minutes just by restructuring queries to fold properly. For any analyst, especially those doing no-code work, this is low-hanging fruit for massive performance gains.
Have you tried optimizing with Query Folding? I’d love to hear your experience. drop me a comment below or connect with me on LinkedIn.