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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
datapal04
Helper I
Helper I

Query Folding with Complex Native Queries

Hello,

I have several native queries I'm using to get data into Power BI from SQL Server (using SQL statements - advanced option). Some of my native queries are complex - some include joins or performing counts. I'm unable to achieve query folding (at least according to this method here) - I get an error saying the query cannot be folded. 

I would like to know if queries as complex as this can achieve query folding? I'm finding the only way to do this effectively is to have a view created and having a "select *" to get that data. Ultimately, I am trying to achieve incremental refresh. Any advice would be great!

3 REPLIES 3
ppm1
Solution Sage
Solution Sage

If you can't get folding to occur with Value.NativeQuery, you can always create datetime parameters called RangeStart and RangeEnd and concatenate those into your SQL statement WHERE clause too. This video shows an example - (1) Natives Queries or ODBC with Incremental Refresh in Power BI - YouTube

 

Pat

Microsoft Employee

Hi @ppm1 , I tried following the video you shared by creating a dataflow but I run into the error below while trying to authenticate for it. My database is on-prem... could this be a reason why I am unable to achieve query folding for incremental refresh?Capture2.JPG

Can you get it to work in a query in Power BI Desktop? Is the issue only when you try it via Dataflow? If so, do you have a gateway set up?

 

Pat

Microsoft Employee

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.