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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Expression Error with Power Query List.Generate()

Hi,

 

I am trying to invoke a custom function in power query to check Next Scheduled Dates against todays date and add a specific interval if the date has alredy passed. The point of this procedure is to update next due dates for reoccuring tasks.

 

I used the List.Generate() function to create an iteration that adds a specific interval to the Next Due Date until the date is after today's date:

 

= (NextScheduledDate as date, NumberOfIntervals as number)=>
List.Generate(
()=>NextScheduledDate,
each _ < DateTime.Date(DateTime.LocalNow()),

Date.AddDays(NextScheduledDate,NumberOfIntervals)
)

 

However, when I try to invoke this function I get the following error:

 

An error occurred in the ‘Query2’ query. Expression.Error: We cannot convert the value #date(2019, 3, 19) to type Function.
Details:
    Value=3/19/2019
    Type=Type

 

NextDueDate is pulling from a date column and it appears that a date cannot be used as a function. Is there a way around this error?

 

Thank you!

3 REPLIES 3
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous ,

Based on my research, I am afraid this function could not just recognize the data value, you could refer to below link:

https://www.mattmasson.com/2014/02/creating-a-date-dimension-with-a-power-query-script/

And below link could help you solve the problem:

https://community.powerbi.com/t5/Desktop/Generate-Customer-Calendar-using-today-s-date-as-end-date/t...

= DateFunction(StartDate, Date.AddDays(DateTime.Date(DateTime.LocalNow()),1), null)

 

Regards,

Daniel He 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the help, however I am not looking to create a custom calendar. I already have a column of Due Dates from my data source that I want to regularly update based on today's date and the task frequency (i.e. the due date is every 2 weeks, or every month..). The function should check the due date with today's date and add a certain amount of days until the due date is after today's date.

 

Thanks!

Hi  

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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 Solution Authors