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)=>
each _ < DateTime.Date(DateTime.LocalNow()),
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.
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?
Hi @powerbiuser132 ,
Based on my research, I am afraid this function could not just recognize the data value, you could refer to below link:
And below link could help you solve the problem:
= DateFunction(StartDate, Date.AddDays(DateTime.Date(DateTime.LocalNow()),1), null)
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.
Could you please help to solve this problem with M code?