Forum Discussion
Query Folding Details for Power BI
- Anonymous1 year ago
Hi Sudip_J ,
Thanks for reaching out to the Microsoft fabric community forum.Here are the links to assist you in understanding and implementing query folding in Power BI when connecting to SQL Server and MySQL data sources:
1. Query Folding Basics
-
https://learn.microsoft.com/en-us/power-query/query-folding-basics
-
Provides an overview of query folding, its benefits, and how Power Query translates steps into native queries.
2. Power Query M Language Specification
-
https://learn.microsoft.com/en-us/powerquery-m/power-query-m-language-specification
-
Offers detailed information on the M language used in Power Query for data transformations.
3. Connect to MySQL Database from Power Query Desktop
-
https://learn.microsoft.com/en-us/power-query/connectors/mysql-database
-
Step-by-step guide on connecting Power BI to a MySQL database using Power Query.(learn.microsoft.com)
4. Connect to SQL Server Database from Power Query Desktop
-
https://learn.microsoft.com/en-us/power-query/connectors/sql-server
-
Instructions on establishing a connection between Power BI and SQL Server databases.
5. Power Query Documentation Hub
-
Central hub for all Power Query documentation, including connectors, transformations, and performance optimization.
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Best Regards,
Sreeteja.
Community Support Team -
Hi Sudip_J ,
Great set of questions. Query folding is a key concept in Power BI performance tuning, especially when working with large datasets from SQL Server or MySQL. Let me walk you through each point with some examples.
(i) How to connect Power Query transformation process in SQL Server or MySQL
You can connect to SQL Server using:
Home > Get Data > SQL Server
Once connected, Power Query Editor lets you apply transformations like filtering, grouping, merging, etc.
(ii) How transformation process in Power Query goes to directly at native data source
This is where query folding comes in. When you apply transformations in Power Query (like filtering rows or renaming columns), Power BI tries to translate those steps into SQL and push them back to the source.
For example:
= Table.SelectRows(Source, each [Region] = "West")
gets translated to:
SELECT * FROM Sales WHERE Region = 'West'
You can check if folding is happening by right-clicking a step in Power Query and selecting "View Native Query". If it's grayed out, folding has stopped at that step.
(iii) How it push back to the native data source
As long as the transformations are foldable, Power BI sends a single SQL query to the source when loading data. This reduces memory usage and speeds up refresh times.
(iv) How it lighten up the power query for dashboard optimization
By folding as much logic as possible to the source, you avoid loading unnecessary data into Power BI. This keeps your model lean and improves performance.
Tips:
- Avoid using custom columns with complex M logic early in the steps
- Keep foldable steps at the top of the query
- Use SQL views if you need more control over folding
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
translation and formatting supported by AI