Forum Discussion

ashutosh's avatar
ashutosh
Helper I
9 years ago
Solved

Find the difference between dates excluding Weekends

Hi,   I have to calculate the difference between two dates but excluding the weekends (Holiday's may in in future) i.e, Sat & Sun  for now.   I checked many threads here all the solutions are wit...
  • v-caliao-msft's avatar
    v-caliao-msft
    9 years ago

    ashutosh,

     

    I have tested it on my local environment, we can add a calculated column to check if the date is working, and then sum up this calculated column.

    Weekday = WEEKDAY('Table'[Date])
    IsWorkingday = IF('Table'[Weekday]>6||'Table'[Weekday]<2,0,1)

    DateDifference =
    var CurrentDate = CALCULATE(MAX(Table1[Date]))
    var PreviousDate = CALCULATE(MAX(Table1[Date]),FILTER(ALL(Table1),Table1[Date]<MAX(Table1[Date])))
    return
    IF(ISBLANK(PreviousDate),BLANK(),
    CALCULATE(SUM('Table'[IsWorkingday]),FILTER(ALL('Table'),'Table'[Date]>=PreviousDate && 'Table'[Date]<CurrentDate)))

     

    Regards,

    Charlie Liao