Forum Discussion
Anett_R
2 years agoFrequent Visitor
Subtract working days from date column
Hello everybody, I have the following issue: I have a date from which I have to subtract the shipping time (in working days) to determine the planned shipping day. In this example,...
dufoq3
2 years agoCommunity Champion
Hi Anett_R, different solution without recursive function:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLUNzDTNzIwMlHSUTJVio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [date = _t, #"shipping time (working days)" = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"date", type date}, {"shipping time (working days)", Int64.Type}}),
Ad_ShippingDate = Table.AddColumn(ChangedType, "shipping date", each
[ a = [#"shipping time (working days)"],
b = List.Dates(Date.AddDays([date], -(a + Number.RoundUp(a/7)*2)), 3, #duration(1,0,0,0)),
c = List.Select(b, (x)=> not List.Contains({5,6}, Date.DayOfWeek(x, Day.Monday))){0}?
][c], type date)
in
Ad_ShippingDate