Forum Discussion
Adding working days to date
- 2 years ago
jimpatel , Try using below measure
Due Date =
VAR CurrentDate = 'Table1'[Date]
VAR DayOfWeek = WEEKDAY(CurrentDate, 2) -- 2 means Monday=1, Tuesday=2, ..., Sunday=7
RETURN
SWITCH(
TRUE(),
DayOfWeek <= 3, CurrentDate + 2, -- Monday to Wednesday
DayOfWeek = 4, CurrentDate + 4, -- Thursday
DayOfWeek = 5, CurrentDate + 4, -- Friday
DayOfWeek = 6, CurrentDate + 4, -- Saturday
DayOfWeek = 7, CurrentDate + 3 -- Sunday
) - Anonymous2 years ago
Hi jimpatel ,
I create a table as you mentioned. Then I create a calculated column and here is the DAX code.
NewDate = VAR StartDate = 'Table'[Date] VAR DaysToAdd = 2 VAR WeekdayNumber = WEEKDAY ( StartDate, 2 ) VAR DaysAdded = SWITCH ( TRUE (), WeekdayNumber + DaysToAdd <= 5, DaysToAdd, WeekdayNumber + DaysToAdd > 5, DaysToAdd + 2 ) RETURN StartDate + DaysAddedFinally I will get what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jimpatel , Try using below measure
Due Date =
VAR CurrentDate = 'Table1'[Date]
VAR DayOfWeek = WEEKDAY(CurrentDate, 2) -- 2 means Monday=1, Tuesday=2, ..., Sunday=7
RETURN
SWITCH(
TRUE(),
DayOfWeek <= 3, CurrentDate + 2, -- Monday to Wednesday
DayOfWeek = 4, CurrentDate + 4, -- Thursday
DayOfWeek = 5, CurrentDate + 4, -- Friday
DayOfWeek = 6, CurrentDate + 4, -- Saturday
DayOfWeek = 7, CurrentDate + 3 -- Sunday
)