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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.