Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

WorkingDays Logic Issue

Dear All, My requirement is to calculate WorkingDays between two dates excluding weekends.   startdate enddate WorkingDays 4/6/2020 4/7/2020 2 5/21/2020   0 5/21/2020 5/21/2020 ...
  • v-yalanwu-msft's avatar
    4 years ago

    Hi, Anonymous ;

    You could modify the dax as follows:

    WorkingDays = 
    VAR YourDate =
        IF ( [enddate] = BLANK (), [startdate], [enddate] )
    var _count=
        COUNTROWS (
            FILTER (
                ADDCOLUMNS (
                    CALENDAR ( [startdate], YourDate ),
                    "Day of Week", WEEKDAY ( [Date], 1 )),
                [Day of Week] <> 1&& [Day of Week] <> 7) )
    return IF([enddate]=BLANK(),0,_count)

    The final output is shown below:

    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.