Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
Hi @AGo.
Patrick tells in this video that there is no query folding at Native Query.
https://www.youtube.com/watch?v=DWbh7xp08l0
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
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
Hi @AGo ,
are you sure that you see the query of the last step and not the query of the preview cache?
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 37 | |
| 33 | |
| 29 | |
| 27 |
| User | Count |
|---|---|
| 134 | |
| 104 | |
| 63 | |
| 60 | |
| 55 |