Skip to main content

Query Folding in Power BI Explained: Why It Can Make Your Reports Much Faster

Query Folding in Power BI Explained: Why It Can Make Your Reports Much Faster




Join My PowerBI Live Classes — https://topmate.io/anurodh_kumar10/2159693?utm_source=public_profile&utm_campaign=anurodh_kumar10

If you’ve ever wondered why one Power BI report refreshes in seconds while another takes several minutes, Query Folding is often part of the answer.

Many Power BI beginners spend time optimizing DAX measures or reducing visual complexity but overlook one of the biggest performance boosters available in Power Query.

In this article, you’ll learn:

  • What Query Folding is
  • Why it’s important
  • How it works
  • How to check if it’s happening
  • Best practices to keep it working

Let’s dive in.


What Is Query Folding?


Query Folding is the process where Power Query translates your transformation steps into a query that runs on the data source instead of inside Power BI.

Instead of downloading all the data and transforming it locally, Power BI asks the source system to perform the work first.

Only the final result is returned to Power BI.

In simple terms:

Let the database do the heavy lifting.

 

A Simple Example

Imagine your SQL Server database contains 10 million sales records.

You only need sales from 2025.


❌ Without Query Folding


Power BI:

  1. Downloads all 10 million rows.
  2. Filters the data locally.
  3. Loads the remaining records.

Result:

  • More data transferred
  • Longer refresh times
  • Higher memory usage

✅ With Query Folding


Power BI sends a request like:

SELECT *
FROM Sales
WHERE Year = 2025;

The database performs the filtering.

Power BI receives only the required rows.

Result:

  • Less data transferred
  • Faster refresh
  • Better overall performance

Why Is Query Folding Important?


Modern databases such as SQL Server, Azure SQL Database, Snowflake, and Synapse are designed to process massive amounts of data efficiently.

When Query Folding is enabled, these systems handle the expensive operations, allowing Power BI to focus on visualization and analysis.

Benefits include:

  • ⚡ Faster refresh times
  • 📉 Lower memory consumption
  • 🌐 Reduced network traffic
  • 🗄️ Better use of database optimization
  • 📊 Improved scalability for large datasets

How Query Folding Works


The process is straightforward:

Connect to Data Source

Apply Transformations

Power Query Translates Steps

Database Executes Query

Power BI Receives Final Result

Power Query continuously evaluates each transformation to determine whether it can be translated into a native query that the data source understands.

If it can, the step is “folded.”


Common Transformations That Usually Fold


Many basic transformations support Query Folding, especially with relational databases.

These include:

  • Filter Rows
  • Remove Columns
  • Rename Columns
  • Change Data Type
  • Sort Rows
  • Keep Rows

Depending on the data source, these may also fold:

  • Merge Queries
  • Group By

Note: Query Folding support depends on the connector and the capabilities of the underlying data source.

 

Transformations That May Break Query Folding


Not every transformation can be translated into a native database query.

Common examples include:

  • Adding an Index Column
  • Running Python scripts
  • Running R scripts
  • Invoking custom functions
  • Using Table.Buffer()
  • Certain complex custom M expressions

Once a step breaks folding, subsequent transformations are usually processed locally by Power BI.


How to Check Whether Query Folding Is Working


Power BI makes this easy.

In Power Query Editor:

  1. Open Applied Steps.
  2. Right-click the latest transformation.
  3. Select View Native Query.

If the option is available

✅ Query Folding is still active.


If the option is disabled

❌ One of the earlier steps has prevented Query Folding.

Checking this periodically while building queries is a good habit, especially when working with large datasets.


Best Practices for Maintaining Query Folding


To get the best performance, follow these recommendations:

1. Filter Early

Reduce the number of rows as soon as possible.

Smaller datasets mean less processing later.


2. Remove Unnecessary Columns

Only keep the columns you need.

This reduces memory usage and network traffic.


3. Keep Transformations Simple

Basic filtering, sorting, and selecting columns are more likely to fold than complex custom logic.


4. Delay Complex Operations

If you need custom M code or advanced transformations, perform them toward the end of the query whenever possible.


5. Check Query Folding Regularly

Use View Native Query after adding major transformation steps.

This helps identify exactly where folding stops.


Does Every Data Source Support Query Folding?


No.

Query Folding depends on the connector and the data source.

Generally, relational databases provide the best support.

Examples include:

  • SQL Server
  • Azure SQL Database
  • Azure Synapse Analytics
  • PostgreSQL
  • Oracle
  • Snowflake

For flat files such as Excel or CSV, there is no query engine behind the source, so Query Folding does not apply.


Common Beginner Misconception


Many people assume that every transformation in Power Query automatically improves performance.

That’s not always true.

A transformation that breaks Query Folding can force Power BI to process large amounts of data locally, leading to slower refreshes.

The goal isn’t simply to apply transformations — it’s to apply them in a way that allows the source system to do as much work as possible.


Quick Memory Trick


Think of Query Folding like ordering food at a restaurant.


Without Query Folding

You bring home every ingredient and cook the meal yourself.


With Query Folding

The restaurant prepares the meal, and you only receive the finished dish.


Similarly, let the database prepare the data before it reaches Power BI.

Query Folding is one of the most valuable performance features in Power BI, yet it’s often overlooked by beginners.

By allowing the data source to perform transformations, you reduce data movement, improve refresh times, and build more scalable solutions.

Whenever you’re working in Power Query, remember this simple principle:

Move the work closer to the data.

The more processing your database performs, the less work Power BI has to do — and the faster your reports are likely to be.


Key Takeaways


  • Query Folding pushes transformations to the data source.
  • It reduces data transfer and speeds up refreshes.
  • Basic transformations usually support folding.
  • Some advanced operations can break folding.
  • Use View Native Query to verify if folding is still active.
  • For supported data sources, keeping Query Folding active as long as possible is a Power BI performance best practice.

If you found this article helpful, follow me for more beginner-friendly content on Power BI, Microsoft Fabric, DAX, Power Query, Data Modeling, and Performance Optimization.

Join My PowerBI Live Classes — https://topmate.io/anurodh_kumar10/2159693?utm_source=public_profile&utm_campaign=anurodh_kumar10

Comments

Popular posts from this blog

Why Do People Dislike DAX and Data Modeling in Power BI?

Why Do People Dislike DAX and Data Modeling in Power BI? Many Power BI users express frustration with DAX (Data Analysis Expressions) and data modeling , primarily due to their complexity and steep learning curves.  Reasons Why People Dislike DAX Steep Learning Curve : DAX has a syntax that can feel unintuitive for newcomers, especially for those without prior experience in Excel's Power Pivot or similar analytical languages. The concept of row context vs. filter context is often confusing and requires significant effort to master. Complexity of Advanced Calculations : Basic measures like sums and averages are straightforward, but creating advanced measures (e.g., time intelligence, ranking, or cumulative totals) can quickly become overwhelming. Many users struggle with understanding functions like CALCULATE , FILTER , and ALL , which are essential for advanced analytics. Error Handling : DAX error messages are not always clear or descriptive, making it difficult to debug issues ...

Connecting Power BI to Azure Data Lake: Streamlining Big Data Analytics

Connecting Power BI to Azure Data Lake: Streamlining Big Data Analytics Azure Data Lake and Power BI provide a powerful combination for businesses to handle and analyze large datasets efficiently. Here’s a step-by-step breakdown of how connecting Power BI to Azure Data Lake helps streamline big data analytics. 1. What is Azure Data Lake? Azure Data Lake is a cloud-based storage solution designed to handle large volumes of structured and unstructured data. It provides highly scalable and cost-effective storage, making it an ideal choice for big data projects, data lakes, and large-scale analytics. 2. Benefits of Connecting Power BI to Azure Data Lake Handling Large Datasets : Power BI’s integration with Azure Data Lake allows users to work with large datasets without needing to import all the data into Power BI. Instead, users can connect and query data directly. Scalable Analytics : Azure Data Lake’s ability to scale horizontally ensures that it can handle growing volumes of data se...

Leveraging Power BI's Bookmarks and Selections for Interactive Dashboards

Leveraging Power BI's Bookmarks and Selections for Interactive Dashboards Bookmarks and Selections in Power BI are powerful features that can significantly enhance the interactivity and user experience of dashboards. Here's how you can use them effectively: 1. What are Bookmarks in Power BI? Bookmarks capture the current state of a report page, including: Visible or hidden visuals Filter states Slicer selections Sort order, drill state, and focus mode By saving different views of your report with bookmarks, you can create interactive storytelling, custom navigation, and dynamic reports. 2. What is the Selection Pane? The Selection Pane lets you control the visibility of report visuals. Using the pane, you can: Show or hide visuals based on user actions Layer visuals in an orderly manner to control how users interact with them Combine with bookmarks to toggle the visibility of different report components 3. Use Cases for Bookmarks and Selections Here are some common scenarios ...