The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi everyone, Can someone explain query folding in Power BI? How does it work ?
Thanks in advance
Solved! Go to Solution.
The goal of query folding is to offload or push as much of the evaluation of a query to a data source that can compute the transformations of your query.
The query folding mechanism accomplishes this goal by translating your M script to a language that can be interpreted and executed by your data source. It then pushes the evaluation to your data source and sends the result of that evaluation to Power Query.
This operation often provides a faster query execution than extracting all the required data from your data source and running all transforms required in the Power Query engine.
https://learn.microsoft.com/en-us/power-query/query-folding-basics
Query folding is a process in Power BI where the steps of data transformation applied in the Power Query Editor are translated into native query language, which is then executed directly in the data source. This means that instead of pulling all the data into Power BI and then applying transformations, Power BI pushes the transformations back to the data source, allowing the source system to handle the heavy lifting. This can significantly improve performance and efficiency, especially when dealing with large datasets
When you apply transformations in Power Query, such as filtering rows, adding columns, or merging tables, Power BI tries to translate these steps into a single query that the data source can understand and execute. This process is known as query folding. If all the steps can be folded, the data source returns only the transformed data to Power BI, reducing the amount of data that needs to be transferred and processed.
Imagine you have a SQL Server database with a table containing sales data. You want to filter the data to include only sales from the last year and then group the data by product category. In Power Query, you would apply a filter step and a group by step. If query folding is possible, Power BI will generate a SQL query that includes both the filter and group by operations, and the SQL Server will execute this query and return only the aggregated data for the last year.
You can check if query folding is occurring by right-clicking on a step in the Power Query Editor and selecting "View Native Query." If the option is available, it means that the step is being folded into the native query. If it's grayed out, it means that query folding is not happening for that step.
Not all data sources and transformations support query folding. For example, some custom transformations or data sources without native query capabilities may prevent query folding. In such cases, Power BI will handle the transformations locally, which may impact performance.
Query folding is a process in Power BI where the steps of data transformation applied in the Power Query Editor are translated into native query language, which is then executed directly in the data source. This means that instead of pulling all the data into Power BI and then applying transformations, Power BI pushes the transformations back to the data source, allowing the source system to handle the heavy lifting. This can significantly improve performance and efficiency, especially when dealing with large datasets
When you apply transformations in Power Query, such as filtering rows, adding columns, or merging tables, Power BI tries to translate these steps into a single query that the data source can understand and execute. This process is known as query folding. If all the steps can be folded, the data source returns only the transformed data to Power BI, reducing the amount of data that needs to be transferred and processed.
Imagine you have a SQL Server database with a table containing sales data. You want to filter the data to include only sales from the last year and then group the data by product category. In Power Query, you would apply a filter step and a group by step. If query folding is possible, Power BI will generate a SQL query that includes both the filter and group by operations, and the SQL Server will execute this query and return only the aggregated data for the last year.
You can check if query folding is occurring by right-clicking on a step in the Power Query Editor and selecting "View Native Query." If the option is available, it means that the step is being folded into the native query. If it's grayed out, it means that query folding is not happening for that step.
Not all data sources and transformations support query folding. For example, some custom transformations or data sources without native query capabilities may prevent query folding. In such cases, Power BI will handle the transformations locally, which may impact performance.
The goal of query folding is to offload or push as much of the evaluation of a query to a data source that can compute the transformations of your query.
The query folding mechanism accomplishes this goal by translating your M script to a language that can be interpreted and executed by your data source. It then pushes the evaluation to your data source and sends the result of that evaluation to Power Query.
This operation often provides a faster query execution than extracting all the required data from your data source and running all transforms required in the Power Query engine.
https://learn.microsoft.com/en-us/power-query/query-folding-basics