cancel
Showing results for
Did you mean:
Frequent Visitor

## Calculating average of last 5 values

I am bringing in streaming data from a machine into PowerBI. I would like to take the last 5 values and create a rolling average of those last 5 values to populate into a visualization.

Time      Value   Rolling Average

0920      5

0915      6

0910      5

0905      7

0900      5

Rolling Average at 0920 = 5.60

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

## Re: Calculating average of last 5 values

@tabhowells

I suggest you add an index column in your table. Then you can create a measure like below:

```Last 5 Average =
CALCULATE (
SUM ( Table[Value] ),
FILTER (
ALL ( Table ),
Table[Index] <= MAX ( Table[Index] )
&& Table[Index]
> MAX ( Table[Index] ) - 5
)
)```

Regards,

Moderator

## Re: Calculating average of last 5 values

@tabhowells

I suggest you add an index column in your table. Then you can create a measure like below:

```Last 5 Average =
CALCULATE (
SUM ( Table[Value] ),
FILTER (
ALL ( Table ),
Table[Index] <= MAX ( Table[Index] )
&& Table[Index]
> MAX ( Table[Index] ) - 5
)
)```

Regards,

Announcements

#### Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

#### Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors