Forum Discussion

RobBeijers312's avatar
1 year ago
Solved

In need help with a measure for difference between two rows

For a report I need the accrual of vacation hours per year and per leave definition. This can be calculated by subtracting the column "leavehoursbalance" from the column "Totalentitlementhours" next ...
  • bhanu_gautam's avatar
    bhanu_gautam
    1 year ago

    RobBeijers312 Try using this version

     

    Accrual =
    VAR CurrentYear = MAX('Table'[year])
    VAR PreviousYear = CurrentYear - 1
    VAR CurrentEntitlement =
    CALCULATE(
    SUM('Table'[totalentitlementhours]),
    'Table'[year] = CurrentYear
    )
    VAR PreviousBalance =
    CALCULATE(
    SUM('Table'[leavehoursbalance]),
    'Table'[year] = PreviousYear
    )
    RETURN
    IF(
    ISBLANK(PreviousBalance),
    BLANK(),
    CurrentEntitlement - PreviousBalance
    )