Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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
  • Hi Anonymous 

    Please refer to attached file with the solution.

    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] )

     

3 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

    Please refer to attached file with the solution.

    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's avatar
      Anonymous
      Not applicable

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


      Is there something I can do about it?

      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        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.