Forum Discussion

Ghaston's avatar
Ghaston
Helper I
7 years ago

rolling average by half hour

hi 
i'm using power query to connect with a SQL base that refeshes every 5 min.
I have a column named "Date_Heure" in the " Date/time " form. 
I have a column named "Arche-Total_Entres" that i want to average for each line ( ligne 11, ligne 12, ligne 13, ligne 14 and ligne 16 in "Ligne" Column. 
Knowing that i'm using Direct Query, how can i run the average of "Arche-Total_Entres" column every half hour ?? 

please help 

16 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    Hi Ghaston,

     

    Have you created the column? If you refresh the report, all the columns will be refreshed automatically. 

     

    Best Regards,

    Dale

    • Ghaston's avatar
      Ghaston
      Helper I

      Hi v-jiascu-msft
      i have no problem with refreshing my Dashboard. 
      I'm using Direct Query, so my model refeshes automatically, and for every 5mn, a new line is added to my data.  
      I juste want to calculate the average of ""Arche-Total_Entres" all the 30 minutes. 


      • v-jiascu-msft's avatar
        v-jiascu-msft
        Microsoft Employee

        Hi Ghaston,

         

        You can create a measure. What is exactly the "all the 30 minutes" and "every 30 minutes"? Is it the latest 30 minutes? Maybe you can try this formula that calculates the average of the latest 30 minutes.

        Measure =
        VAR maxTime =
            CALCULATE ( MAX ( 'Table1'[Date_Heure] ), ALL ( 'Table1' ) )
        RETURN
            CALCULATE (
                AVERAGE ( Table1[Arche-Total_Entres] ),
                FILTER (
                    'Table1',
                    'Table1'[Date_Heure] <= maxTime
                        && 'Table1'[Date_Heure]
                            >= maxTime - TIME ( 0, 30, 0 )
                )
            )
        

         

        Best Regards,

        Dale