cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## Making a moving average backwards

Hello everyone!
I Have the follow problem, I want to do a moving average backwards.
for example, as the table below:

 Date Value 01/01/2019 10 02/01/2019 11 03/01/2019 14 04/01/2019 15 05/01/2019 18 06/01/2019 19 07/01/2019 18 08/01/2019 20 09/01/2019 14 10/01/2019 25

So what I want to show is: On date 10/01/2019, the value that must show is 25.
On day 09/01/2019, it must show the average between day 10 and 9, given me a total of 19,5  (That is (20+14)/2)
On day 08/01, it must show an average of the days 10, 9 and 8, given me a total of 19,6 (That is (20+14+25)/3)
On day 07/01 must show the average of the day 10,9,8,7 and so on....

How can I do this?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team

## Re: Making a moving average backwards

Hi @gertjvr

You may create a measure like below:

```Measure =
DIVIDE (
CALCULATE (
SUM ( Table2[Value] ),
FILTER ( ALL ( Table2 ), Table2[Date] >= MAX ( Table2[date] ) )
),
COUNTROWS ( FILTER ( ALL ( Table2 ), Table2[Date] >= MAX ( Table2[date] ) ) )
)
```

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Community Support Team

## Re: Making a moving average backwards

Hi @gertjvr

You may create a measure like below:

```Measure =
DIVIDE (
CALCULATE (
SUM ( Table2[Value] ),
FILTER ( ALL ( Table2 ), Table2[Date] >= MAX ( Table2[date] ) )
),
COUNTROWS ( FILTER ( ALL ( Table2 ), Table2[Date] >= MAX ( Table2[date] ) ) )
)
```

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Established Member

## Re: Making a moving average backwards

```let
Source = Web.Page(Web.Contents("https://community.powerbi.com/t5/Desktop/Making-a-moving-average-backwards/m-p/649510#M311441")),
Data0 = Source{0}[Data],