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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
pacofq
Advocate I
Advocate I

Power Query - Next Work Day

 

Hi evryone,

 

I have a date table structured like this

 

[Date]

2017-01-01

2017-01-02

...

 

I'm trying to generate a calculated column that return the "next work (open) day" relative to my [Date] column

I managed to generate a column that identifies if the date is a WORKDAY or a NOWORKDAY by verifying if its a saturday, a sunday or if the date is a Holiday (by looking in my holiday table (T_FERIES)), but i'm not able to calculate the next open day

 

let
    Source = Excel.Workbook(File.Contents("\\DATES.xlsx"), null, true),
    T_DATES_Table = Source{[Item="T_DATES",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(T_DATES_Table,{{"Date", type date}}),
    #"MERGE - T_FERIES" = Table.NestedJoin(#"Changed Type",{"Date"},T_FERIES,{"JourCal"},"T_FERIES",JoinKind.LeftOuter),
    #"EXPAND - Feries" = Table.ExpandTableColumn(#"MERGE - T_FERIES", "T_FERIES", {"JourCal"}, {"Ferie"}),
    #"Added Conditional Column" = Table.AddColumn(#"EXPAND - Feries", "WORKDAY", each if [Ferie] <> null or Date.DayOfWeek(Date.From([Date])) = 0 or Date.DayOfWeek(Date.From([Date])) = 6 then "NOWORKDAY" else "WORKDAY"),
    #"Added Custom" = Table.AddColumn(#"Added Conditional Column", "MinWorkDay", each List.Min(Table.SelectRows(#"Added Conditional Column"[Date], [WORKDAY] = "WORKDAY"),type number))
in
    #"Added Custom"

 

Here's what my table looks like right now. I'm trying to fill the 4th column with the "Next Work Day"

 

2018-11-20 15-47-40.png

If anyone could help it would be much appreciated!!

 

Thanks in advance!

 

 

 

 

1 REPLY 1
Zubair_Muhammad
Community Champion
Community Champion

@pacofq

 

Try adding this new custom column

 

 

=let mydate=Date.DayOfWeek(Date.From([Date])) in
if mydate=5 then Date.AddDays([Date],3)
 else 
if List.AnyTrue({mydate=0,mydate=6})=false 
then 
Date.AddDays([Date],1)
 else null

= Table.AddColumn(#"Added Custom", "Custom", each let mydate=Date.DayOfWeek(Date.From([Date])) in
if mydate=5 then Date.AddDays([Date],3) else if List.AnyTrue({mydate=0,mydate=6})=false then Date.AddDays([Date],1) else null)

 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.