Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Bokchoy
Helper II
Helper II

Query Folding compared to writing SQL statement

Hi all,

 

 

When importing data from SQL, i usually load in the data alongside a pre-written SQL statement with most transformation defined. From my understanding of QueryFolding, it does the exact same thing for you step by step with each transformation done on PowerQuery.


Is there any difference in performance given that transformation is identical between both methods? Wouldn’t having a pre-written SQL statement be more efficient on the SQL side and prevent potential table locking?
Also, can i enable Queryfolding after hand when I import the data with an SQL script?

 

 

 

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Bokchoy 
Pre-written SQL statement with NO power query transformations is the most efficient.
If you use it then you can't add power query steps or you will lose folding.
If you use the GUI of Power Query then you can also achieve Query folding but that's depend on the transformations you do. 
You can check to see if the query is folded by right clicking the last step and view the native query if available. Best thing is to check with SQL profiler what is the queries being sent to the data source to verify if there was a query folding or not.



2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

1 REPLY 1
SpartaBI
Community Champion
Community Champion

@Bokchoy 
Pre-written SQL statement with NO power query transformations is the most efficient.
If you use it then you can't add power query steps or you will lose folding.
If you use the GUI of Power Query then you can also achieve Query folding but that's depend on the transformations you do. 
You can check to see if the query is folded by right clicking the last step and view the native query if available. Best thing is to check with SQL profiler what is the queries being sent to the data source to verify if there was a query folding or not.



2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.