Forum Discussion

Walt1010's avatar
Walt1010
Helper V
1 year ago
Solved

Sum everything within a date range (cumulatively)

Noob here.   I have a table of dates, indicating dates on which employees took a sickness leave day. I need to calculate the sum of all the sickness leave days taken over the past 2 years, at any d...
  • bhanu_gautam's avatar
    1 year ago

    Walt1010 , Try using

    CumulativeSicknessLeave =
    VAR CurrentDate = MAX(sicknesstable[sicknessdate])
    RETURN
    CALCULATE(
    COUNT(sicknesstable[sicknessdate]),
    FILTER(
    ALL(sicknesstable),
    sicknesstable[sicknessdate] <= CurrentDate &&
    sicknesstable[sicknessdate] >= DATEADD(CurrentDate, -2, YEAR)
    )
    )