Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Average of 3 weeks without using time intellige functions

Hi there, I'm trying to create a kind rolling average over the last 3 weeks but without using time intelligent functions.   My excel looks like this:    A B C D E F G 1   WEEK 1 W...
  • jgeddes's avatar
    4 years ago

    If I understand correctly, you can create a table of averages

    Averages Table =
    SUMMARIZE(dimDate,dimDate[Week],"_averages",DIVIDE(SUM(factItems[Observations]),SUM(factItems[Items])))
    and then create a measure from that table
    Rolling 3 Week Average =
    var _currentWeek =
    SELECTEDVALUE(dimDate[Week])
    var _firstWeek =
    _currentWeek - 2
    Return
    IF(
        _firstWeek > 0,
        CALCULATE(
            AVERAGE('Averages Table'[_averages]),
            FILTER(all('Averages Table'), 'Averages Table'[Week] >= _firstWeek && 'Averages Table'[Week] <= _currentWeek)
        )
    )