cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
niel_orvyn1
Helper III
Helper III

Rolling average per minute

Rolling average per second and minute

 

I need help on a moving average per second and minute. I’ve surfed the web for many days now, I’ve tried most of the posted solutions but I cannot seem to crack it.

 

I’m trying to determine a moving average for events [TPS] per time stamp, in this case the rolling average looking at seconds in a minute. Once I have total events per second, I would like to calculate the rolling average per minute.

 

I’ve created a new table with ‘DateTimeTable’  so I could have a calendar with all-time stamps for a period (this case 3 months), and used a left outer join to join it with the table ‘TokenMA60’ containing the data. The [ifisblank] looks if an event 'TokenMA

' occured and if not returns a zero or if, a value of 1. I tried using a below or over fuction that can be done with SQL. 

 

Below I have an excel example of what I would like to achieve, rather easy with a pivot:

Example Excel.png

 

Below the data in Power Bi (desktop)

PBI RollAVG Screenshot.png

 

Has anyone ever achieved this in with DaX/PowerBi? 

 

Regards

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @niel_orvyn1 ,

 

We can use the following steps to meet your requirement.

 

1. We need to create a new calculate column to get the every minute.

 

Datetime 1 = FORMAT('Table'[Datetime],"YYYY/mm/dd hh:mm:00")

 

Rolling 1.jpg

 

2. Then create a measure. You can replace the SUM with AVERAGE.

 

Measure = CALCULATE(SUM('Table'[ifisblank]),FILTER(ALLSELECTED('Table'),'Table'[Datetime]<=MAX('Table'[Datetime])))

 

And create a table, put the [Datetime 1] and [Measure] in it. The result like this, 

 

Rolling 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-zhenbw-msft
Community Support
Community Support

Hi @niel_orvyn1 ,

 

We can use the following steps to meet your requirement.

 

1. We need to create a new calculate column to get the every minute.

 

Datetime 1 = FORMAT('Table'[Datetime],"YYYY/mm/dd hh:mm:00")

 

Rolling 1.jpg

 

2. Then create a measure. You can replace the SUM with AVERAGE.

 

Measure = CALCULATE(SUM('Table'[ifisblank]),FILTER(ALLSELECTED('Table'),'Table'[Datetime]<=MAX('Table'[Datetime])))

 

And create a table, put the [Datetime 1] and [Measure] in it. The result like this, 

 

Rolling 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-zhenbw-msft 

Apologies for back tracking:

 

When I use as per below  "2. Then create a measure. You can replace the SUM with AVERAGE."

It works perfectly the column with [Datetime], the one that contains seconds:

 

MeasureAVG = CALCULATE(AVERAGE('Table'[ifisblank]),FILTER(ALLSELECTED('Table'),'Table'[Datetime]<=MAX('Table'[Datetime])))
 
 

MEASUREAVG.png

However on the right hand column containing [Datetime 1], its appears to give the moving average per the [Datetime] column. For the moving average where I would like to calculate:

Moving average.png Hope  my question is making sense. 

 

Let me know if you can help. 

 

Many thanks,

Niel

 

Hi

@v-zhenbw-msft  am very gratefull, I've spent days searching for the solution, I've googled almost every topic in this regard. 

If you have any links for ramp up of PowerBi skills please share. I've done DAT207x however, it only touches the surface of PowerBi, just my opinion and want to learn more. 

Best,

Niel

amitchandak
Super User IV
Super User IV

This Avg should reset every day or continue as is?



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Hi 

The avg should continue and not reset everyday. The orig data is events over a 3 months period and I would like to see the average of events over the 3 months. 

Thanks in advance.

Regards,

Niel

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors