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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Aaron301
Frequent Visitor

Query folding using a previous query to filter

 
Hello. I am working with a dataflow gen2 in Fabric and trying to filter my main query by a max date that I get from my lakehosue. When I do this the query stops folding so I had to insert a step to filter by a static number of days before it to make it manageable as a workaround.
 
Is there anyway to do this in a way that the query folds?
 
Thanks in advance!
 
Last_Activity_Date:
Aaron301_0-1692642797014.png

 

Main Query: 

Aaron301_1-1692642797014.png

 

 

2 REPLIES 2
GilbertQ
Super User
Super User

Hi @Aaron301 

 

In your dataflow gen2 you could use the table called "Last_Activity_Date" and on the table right click and select Drill Down. This will result in the table having a single value which you can then re-use.

 

Then in your Main query where you have got the filter you could use the table name as the filter.

This is what you are looking for after the drill down

GilbertQ_0-1692654088683.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Thanks for the quick reply but Last_Activity_Date is already returning a single value as a DateTime and I am already calling that in the main query as you said.

 

I know that you can't append queries without breaking folding but it seems silly that it wouldn't be able to use the value from the first query as a variable in the Where predicate so I feel like I must be doing something wrong.

 

I copied and pasted the value returned from the first query, converted it to a DateTime and replaced the call to it in the main query with it and it folds. If I use the DateTime returned from Last_Activity_Date the data returned is correct but it doesn't fold.

 

Folds:

Aaron301_0-1692670415188.png

Doesn't fold:

Aaron301_1-1692670634866.png

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.

Top Kudoed Authors