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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
AGo
Post Patron
Post Patron

Query folding not working without message errors

Hello,

I'm trying to use query folding in order to activate incremental refresh.

This is my query:

let
Source = Value.NativeQuery(PostgreSQL.Database("server", "db", [CreateNavigationProperties=false]), "select * from table1#(lf)union select * from table2", null, [EnableFolding=true]),
#"Filtrate righe" = Table.SelectRows(Source, each [timestamp] <> null and [timestamp] <> ""),
INCREMENTAL = Table.SelectRows(#"Filtrate righe", each [timestamp] >= RangeStart and [timestamp] < RangeEnd),..........

 

RangeStart and RangeEnd are parameters requested to activate incremental refresh.

If I click on Show Native Query on the INCREMENTAL step (which is the last step with this option) it returns correct sql with WHERE statement.

If I look on my postgres db at the query received by DBMS that is running, it is not the folded query but the first one declared in the Source step of mquery.

How can I solve this?

 

Thanks

4 REPLIES 4
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @AGo.

 

Patrick tells in this video that there is no query folding at Native Query.

https://www.youtube.com/watch?v=DWbh7xp08l0

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Are you sure? Whene he's speaking about query folding non-functioning the function he's using doesn't contains a Value.NativeQuery function. I instead succeed in viewing the native query result on my third step, the problem is that PowerBI doesn't send it to the DBMS correctly.

Maybe @ImkeF can help.

 

Thanks

ImkeF
Community Champion
Community Champion

Hi @AGo 

To my knowledge, Query folding will stop after you've used individual SQL code.

In your case, in the Source-step.

So your result doesn't surprise me.

But what I find surprising though, is that the native queries are shown in the subsequent steps.

How sending that query in the first step (Source) instead?

 

Edit: Check this post how to include query parameters into native SQL-calls: https://community.powerbi.com/t5/Desktop/Parameterized-SQL-Query-with-query-folding/td-p/171503 

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @AGo ,

 

are you sure that you see the query of the last step and not the query of the preview cache?

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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