Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

A rolling average per half hour

Hi,

 

I would like to calculate a rolling average per 30 minutes in large amount of data. Every minute a machine registers data. I want to see an average value over the PAST 30 minutes in THAT specific minute. So for example in minute 4 - an average of the past 30 minutes in values and in minute 57 - an average of the past 30 minutes in values.

 

I hope someone can help me with this.

 

The example that i am working on:

2150635-8-2022 00:060
2150645-8-2022 00:070
2150655-8-2022 00:084,23
2150665-8-2022 00:0912
2150675-8-2022 00:109,89
2150685-8-2022 00:110
2150695-8-2022 00:120
2150705-8-2022 00:130
2150715-8-2022 00:140
2150725-8-2022 00:158,12
2150735-8-2022 00:168,89
2150745-8-2022 00:1710,12
2150755-8-2022 00:1811,45
2150765-8-2022 00:190
2150775-8-2022 00:200
2150785-8-2022 00:210
2150795-8-2022 00:220
2150805-8-2022 00:230
2150815-8-2022 00:240
2150825-8-2022 00:250
2150835-8-2022 00:260
2150845-8-2022 00:271,89
2150855-8-2022 00:280
2150865-8-2022 00:290
2150875-8-2022 00:300
2150885-8-2022 00:310
2150895-8-2022 00:320
2150905-8-2022 00:330
2150915-8-2022 00:340
2150925-8-2022 00:351,82
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

Please refer to attached file with the solution.

1.png

Rolling Average = 
VAR CurrentTime = Data[TimeStamp]
VAR PreviousTime = CurrentTime - TIME ( 0, 30, 0 )
VAR FilteredTable = FILTER ( Data, Data[TimeStamp] <= CurrentTime && Data[TimeStamp] > PreviousTime )
RETURN
    AVERAGEX ( FilteredTable, Data[Value] )

 

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

Please refer to attached file with the solution.

1.png

Rolling Average = 
VAR CurrentTime = Data[TimeStamp]
VAR PreviousTime = CurrentTime - TIME ( 0, 30, 0 )
VAR FilteredTable = FILTER ( Data, Data[TimeStamp] <= CurrentTime && Data[TimeStamp] > PreviousTime )
RETURN
    AVERAGEX ( FilteredTable, Data[Value] )

 

Anonymous
Not applicable

That is exactly what I need. I tried this and I still have one issue though...

Schermafbeelding 2022-11-02 154841.png
Is there something I can do about it?

@Anonymous 
The provided code is a calculated column not a measure. If you are looking for a measure, please check the sample file and amend it witht the eaxpexcted visual then share it with me.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.