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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
amby0430
Frequent Visitor

Calculate due date based on SLA excluding weekends and holidays date conversion error

I am stuck, hoping someone can help me figure out this calculation. I have a custom function that removes weekends and holidays. This works really great to get days between two dates, however I am now looking to just input a start date and add a standard 90 day SLA and would give the DATE as a result. Below is my function, however my result gives me a conversion error in red. Please help. Thank you!

 

An error occurred in the ‘’ query. Expression.Error: We cannot convert the value #date(2025, 5, 26) to type Number.
Details:
Value=5/26/2025
Type=[Type]

 

Custom Function

 

(StartDate as date) as date =>

let

DateList = List.Dates(StartDate, Date.From(Date.AddDays(StartDate,90)), #duration(1, 0, 0, 0)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, adbe_holiday_calendar),
Result = Date.From(RemoveHolidays)
in

1 ACCEPTED SOLUTION
m_dekorte
Resident Rockstar
Resident Rockstar

Hi @amby0430 

There are two clear issues with your code (assuming adbe_holiday_calendar is a list with date type values).

1. The second argument of List.Dates is expects a count as number and you've provided a date: Date.From(Date.AddDays(StartDate,90))  so I guess 90 will do

2. But Result will throw an error as well, RemoveHolidays returns a list of values and can't be converted to a date, however you can for example extract the last date value from that list.

 

I hope this is helpful

 

(StartDate as date) as date =>
let
    DateList = List.Dates(StartDate, 90, Duration.From(1)),
    RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
    RemoveHolidays = List.RemoveItems(RemoveWeekends, adbe_holiday_calendar),
    Result = List.Last(RemoveHolidays)
in
    Result

 

 

View solution in original post

7 REPLIES 7
Omid_Motamedise
Super User
Super User

The error occurs because RemoveHolidays returns a list of dates, but you are trying to convert it directly to a date type, which is causing the type mismatch. To fix this, you need to calculate the final date after adding 90 business days. Instead of converting the list of dates to a single date, you can return the last date from the list as the result. 

 

 


If my answer helped solve your issue, please consider marking it as the accepted solution.

@Omid_Motamedise I am following the logic, however utilizing the code from @m_dekorte is only giving me the date forward 90 calendar days. Thoughts where I may be missing something? adbe_holiday_calendar is my holiday calendar.

 

= (StartDate as date) as date =>
let
DateList = List.Dates(StartDate, 90, Duration.From(1)),
RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
RemoveHolidays = List.RemoveItems(RemoveWeekends, adbe_holiday_calendar),
Result = List.Last(RemoveHolidays)
in
Result

m_dekorte
Resident Rockstar
Resident Rockstar

Hi @amby0430 

There are two clear issues with your code (assuming adbe_holiday_calendar is a list with date type values).

1. The second argument of List.Dates is expects a count as number and you've provided a date: Date.From(Date.AddDays(StartDate,90))  so I guess 90 will do

2. But Result will throw an error as well, RemoveHolidays returns a list of values and can't be converted to a date, however you can for example extract the last date value from that list.

 

I hope this is helpful

 

(StartDate as date) as date =>
let
    DateList = List.Dates(StartDate, 90, Duration.From(1)),
    RemoveWeekends = List.Select(DateList, each Date.DayOfWeek(_, Day.Monday) < 5),
    RemoveHolidays = List.RemoveItems(RemoveWeekends, adbe_holiday_calendar),
    Result = List.Last(RemoveHolidays)
in
    Result

 

 

I thank you dearly @m_dekorte this worked perfectly. I appreciate that you also helped me understand where I went wrong with the query and didn't just provide me the solve without explaining it. Greatly appreciated!

Anonymous
Not applicable

Hi @amby0430,

 

Thanks @m_dekorte  for Addressing the issue.

 

Glad that your issue is resolved! 😊 Could you please accept it as a solution? This will help other community members with similar issues find the solution faster. 

 

Regards,

Vinay Pabbu

@m_dekorte I have found that the weekends and holidays are not being removed from the calculation. If you could please kindly respond if you have thoughts or a solution I would appreciate it. Thank you.

Hi @amby0430,

 

The most obvious reason would be if values in your adbe_holiday_calendar have a different data type. To illustrate, what would you expect to be the outcome here?

let
    dateTimes = List.DateTimes( DateTime.From(#date(2025, 3, 1)), 10, Duration.From(1)),
    Dates = List.Dates( #date(2025, 3, 2), 9, Duration.From(1)),
    Diff = List.RemoveItems( dateTimes, Dates)
in
    Diff

 

Hope that helps!

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.