Forum Discussion

jimpatel's avatar
jimpatel
Post Patron
2 years ago
Solved

Adding working days to date

Hi,   Thanks for looking at my post.   I am using below formula but for somereason it is not working correctly. What i am looking for is i wanted to add 2 working days extra to "Date" column. If ...
  • bhanu_gautam's avatar
    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
    )

  • Anonymous's avatar
    Anonymous
    2 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 + DaysAdded

    Finally 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.