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
TokyoBI
Regular Visitor

Is there a date function in Power Query which supports Query Folding resulting in CURRENT_DATE?

Is there a date function in Power Query which supports Query Folding? When I currently use a date function the query does not fold anymore. 

 

The following M-code is used to create a new custom column:

 

= if [End Data] = NULL then DateTimeZone.FixedUtcNow() else [End Date]

 

I would like to fold this into something like this

 

case
when "_"."End Date" is null
then CURRENT_DATE
else "_"."End Date"
end

 

5 REPLIES 5
Daryl-Lynch-Bzy
Community Champion
Community Champion

@TokyoBI - I am a big fan of Query Folding, but I am also conscious that it probably won't matter if you import all the data from the Server to the Power BI Client and then add the Current Date.  You may want to use Phil Seamark analysis my refresh Power BI / SQL Profiler to see if there is actually a performance benefit.

The second thing is that I am not really a fan of having the Current Date repeated on every row of the Table.  What is the benefit?  Just a create a second table with 1 row and the current date.  The Data Model will be smaller and this approach is unlikely to impact your reports.

@ImkeF 

Thanks for the feedback. How would you implement it to use the current date when a date field is empty so that the native (SQL) query folds?

 

The following M-code is used to create a new custom column:

 

= if [End Data] = NULL then DateTimeZone.FixedUtcNow() else [End Date]

 

I would like to fold this into something like this

 

case
when "_"."End Date" is null
then CURRENT_DATE
else "_"."End Date"
end

ImkeF
Community Champion
Community Champion

To my understanding, you can do a lot of transformations in a new column without breaking query folding. 
Just don't try to change an existing column.

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

ImkeF
Community Champion
Community Champion

Hi @TokyoBI ,
instead of transforming an exising column, try adding a new one that applies the date conversion and then delete the old one.

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

I would like to perform a transformation which includes the current date; not just a type conversion.

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.