date time format problem with AVERAGEIF (test-values, condition, avg-values) formula

I have a data set with two columns, (A) date/time and (B) meter readings. It has over 15,000 entries (readings taken every 30mins by smart meter over a couple of years).


I'd like to generate a graph showing average hourly use over a 24hr cycle.


I'm trying to use AVERAGEIF (test-values, condition, avg-values) to obtain averages for half hourly intervals but keep running into DIV/0 and other errors:





tried adding a column using the HOUR formula to strip date values:



this works with a simple IF formula, displaying reading when valid and blank when not. I can then get the average for that half hour by highlighting the column. But I'd need to add 48 more columns to cover all the intervals. Seems long winded.


Instead, I thought using AVERAGEIF on the first 48 rows would give me what I needed. But I keep getting errors. One permutation/attempt shown below. I've tried dozens of different approaches but I think AVERAGEIF doesn't like mixing durations or any date/times with other values.




Any thoughts on a better approach?


many thanks,





MacBook Pro 13″, macOS 10.15

Posted on Oct 10, 2021 7:30 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 10, 2021 8:39 AM

Starting with the table in your last screenshot,


D2 = AVERAGEIF(C,C2,B)

Fill down to at least 48 rows to get the averages for all 48 half hour periods.

Delete the formula in E2


D2 will have the average of all reading taken at 00:30

D3 will have the average of all readings taken at 01:00

etc.

3 replies

Oct 10, 2021 9:37 AM in response to SaltSeaShark

You can easily do this kind of thing in a few seconds with some clicks and drags (no formulas!) using the new Pivot Table Functionality:





Click the table with your data and in the menu choose Organize > Create Pivot Table > On Current Sheet.


The formula in column C of the source table is the same as yours.


If you're new to Pivot Tables, or even if you aren't, check out these videos that I have found very helpful:


https://macmost.com/the-new-pivot-table-feature-in-numbers.html


https://macmost.com/macmost-live-working-with-pivot-tables-in-numbers.html



SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

date time format problem with AVERAGEIF (test-values, condition, avg-values) formula

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.