Hourly Averages from 5 Minute Timestamps

UseLessFuel

New Member
Joined
Dec 22, 2012
Messages
37
Hello. I am struggling with what may be quite simple. I am working with timestamped data in dd-mmm-yyyy hh:mm:ss format, where a value occurs every 5 minutes (but not exactly). I require to obtain an hourly average for each and every hour, which would normally be an average of the previous 12 cells (since the data is in 5 minute intervals). Example below:
15-Apr-2011 15:42:15

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 15:47:15

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>

<colgroup><col style="mso-width-source:userset;mso-width-alt:3620;width:74pt" width="99"> </colgroup><tbody>
</tbody>
15-Apr-2011 15:52:16

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 15:57:17

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:02:18

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:07:19

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:12:20

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:17:20

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:22:21

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:27:22

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:32:23

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.9

<colgroup><col width="99"></colgroup><tbody>
</tbody>
15-Apr-2011 16:37:24

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.9

<colgroup><col width="99"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="80"></colgroup><tbody>
</tbody>
15-Apr-2011 16:42:25

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.9

<colgroup><col width="99"></colgroup><tbody>
</tbody>

<tbody>
</tbody>
This particular dataset has 228,000 rows, and while almost all of the time intervals are between 5 minutes exactly, and 5.0333 minutes, there are instances of data-gaps, ranging from one timestamp missing, up to 7 days of data missing (= 2,000 records missing - I use the comma separator as a thousand separator). Also, there may be instances, where an hour of data may take 13 records, instead of 12, due to the slightly irregular time interval gaps. In the Table above, the 3rd column contains the average of the previous 12 records. My goal is to ascertain whether hourly records would be sufficient, since the values in the second column seem to change so little. It looks like I will also need the Max and Min values from each hour: crikey, it does look complex. Using MS Excel 2010, and Windows 7 Professional.

I am not experienced in VBA, although I have tinkered with it in the past. Any ideas?
(I can use Formulas, such as Countifs, Sumifs etc. and also Named ranges)
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
DateRecordYour ResultRefActual Average ResultMax per hourMin per hour
15/04/2011 15:42100.0020114151532.00100.000.00
15/04/2011 15:4714.0020114151532.00100.000.00
19001000.000.00
15/04/2011 15:520.0020114151532.00100.000.00
15/04/2011 15:5714.0020114151532.00100.000.00
15/04/2011 16:0219.8020114151619.8319.9019.80
15/04/2011 16:0719.8020114151619.8319.9019.80
15/04/2011 16:1219.8020114151619.8319.9019.80
15/04/2011 16:1719.8020114151619.8319.9019.80
15/04/2011 16:2219.8020114151619.8319.9019.80
15/04/2011 16:2719.8020114151619.8319.9019.80
15/04/2011 16:3219.9020114151619.8319.9019.80
15/04/2011 16:3719.9019.8020114151619.8319.9019.80
19001000.000.00
15/04/2011 16:4219.9020114151619.8319.9019.80

<tbody>
</tbody>


HI Uselessfuel
I like this one, rarely do i use array formulas, but here you go, try this

Ref
YEAR(A2)&MONTH(A2)&DAY(A2)&HOUR(A2)

Actual Average Result
=IFERROR(AVERAGEIF($D$1:$D$16,D2,$B$1:$B$16),"")

Max per hour
=MAX(IF($B$1:$D$16=D2,$B$1:$B$16))
This will need to cnt shift enter to make an array formula with {} either side

Min per hour
=MIN(IF($B$1:$D$16=D2,$B$1:$B$16))
This will need to cnt shift enter to make an array formula with {} either side

If you are still having issues, I can upload to dropbox for you
 
Last edited:
Upvote 0
Hi Pup Denab. Thanks for reply. I've been delayed, so, sorry about the late reply.

Looking at your post, briefly, I'm wondering where you get your first 4 records from? My, original, first 4 records were all 19.8 , while you have 100, 14, 0 and 14 again. Was this for demonstrative purposes? Will continue to (attempt to) disect.

Regards,

UseLess
 
Upvote 0
Date Time
Record
06-Oct-2011 19:19:56

<colgroup><col width="172"></colgroup><tbody>
</tbody>
18.2

<colgroup><col width="99"></colgroup><tbody>
</tbody>
06-Oct-2011 19:24:57

<colgroup><col width="172"></colgroup><tbody>
</tbody>
18.2

<colgroup><col width="99"></colgroup><tbody>
</tbody>
14-Oct-2011 13:56:50

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>
14-Oct-2011 14:01:51

<colgroup><col width="172"></colgroup><tbody>
</tbody>
19.8

<colgroup><col width="99"></colgroup><tbody>
</tbody>

<tbody>
</tbody>

Hi Pup.

I understand what you have done, and it works well, although with your data, i.e. the different first 4 records, I get 32 in cell E4, whereas you have 0 . Why is this?
However, (and it was my omission from the original post), my data does have gaps, but the gaps do not take up any rows. Example above shows nearly 8 full days missing, but the data is still contained in consecutive rows.

Thanks so far Pup. Again, I may take a while to get back to you.

Regards,

UseLess
 
Upvote 0
Hi
When I copied you data & pasted into excel the gaps where their, so I just left them, I changed the data to test the calculations, sorry for the confusion, however it should work better without gaps. No problem we are here to help
Regards
Pup
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,260
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top