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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lennox25
Post Patron
Post Patron

How to get deadline date excluding weekends and holidays in Power Query

I have a date table and the result table. I had worked out a Deadline Date using the Date of Arrival and the Deadline Days (i.e 2)

 

In Power Query (which im still learning) I have this = Table.AddColumn(#"Filtered Rows1", "Deadline Date", each Date.AddDays([Date of Arrival],[Deadline])) 

 

What do I need to do to exclude the weekends and holidays? One of my rows has 

Date of Arrival = 09/11/23  Deadline Days are 2 (which is a Saturday) the current result is 11/11/2023. I need it to be 13/11/23 (Monday)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @lennox25 ,

Please try this:

let
    DayList = List.Dates([Date of Arrival], 10 + [Deadline], #duration(1,0,0,0)),
    RemoveWeekends = List.Select(DayList, each Date.DayOfWeek(_, Day.Monday) < 5),
    RemoveHolidays = List.Select(RemoveWeekends, each not List.Contains(Holidays[Date], _)),
    Result = List.FirstN(RemoveHolidays, [Deadline] + 1)
in
    if [Deadline] = null then null else List.Last(Result)

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @lennox25 ,

Please create a new holiday table:

vcgaomsft_0-1709781406626.png

And add a custom column use:

let
    DayList = List.Dates([Date of Arrival], 10 + [Deadline], #duration(1,0,0,0)),
    RemoveWeekends = List.Select(DayList, each Date.DayOfWeek(_, Day.Monday) < 5),
    RemoveHolidays = List.Select(RemoveWeekends, each not List.Contains(Holidays[Date], _)),
    Result = List.FirstN(RemoveHolidays, [Deadline] + 1)
in
    List.Last(Result)

vcgaomsft_1-1709781458922.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Genius! If there is no date of arrival is there any way of it not throwing up an error?

Anonymous
Not applicable

Hi @lennox25 ,

Please try this:

let
    DayList = List.Dates([Date of Arrival], 10 + [Deadline], #duration(1,0,0,0)),
    RemoveWeekends = List.Select(DayList, each Date.DayOfWeek(_, Day.Monday) < 5),
    RemoveHolidays = List.Select(RemoveWeekends, each not List.Contains(Holidays[Date], _)),
    Result = List.FirstN(RemoveHolidays, [Deadline] + 1)
in
    if [Deadline] = null then null else List.Last(Result)

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Thank you! Amazing! 

Use the Power Query Coalesce operator ??

lbendlin
Super User
Super User

Have a calendar table available with these dates clearly marked.  Do a merge with your result table to pull that flag in/to filter on it. Or do an anti join etc.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.