Forum Discussion

maurcoll's avatar
maurcoll
Icon for Helper IV rankHelper IV
2 years ago
Solved

Rolling 12 month total

Hi I am trying to calculate the last rolling 12 months data that i can put into a line chart visual. It will need to show monthly going back for 12 months as per the below data. So for Sept 23 it w...
  • jgeddes's avatar
    2 years ago

    A measure like the following might work for you...

    rollingTotalMeasure =
    var _rollingMonths =
    12
    var _maxDate =
    MAXX(
        ALL('Table'),
        [MonthYear]
    )
    Return
    CALCULATE(
        SUM('Table'[Total]),
        FILTER(
            ALL('Table'),
            [MonthYear] <= MAX('Table'[MonthYear]) && DATEDIFF([MonthYear], _maxDate, MONTH) < _rollingMonths
        )
    )