+ Reply to Thread
Results 1 to 9 of 9

Average 24 hours of data when sample rate fluctuates

  1. #1
    Registered User
    Join Date
    01-23-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2003 SP3
    Posts
    7

    Average 24 hours of data when sample rate fluctuates

    I have an Excel spreadsheet with imported data from an AWOS weather station. Column A is the date and time (in standard Excel Date/Time format). Columns B, C, etc are temperature, dew point, etc. There are typically about 3 data samples per hour but this sampling rate is not fixed -- it can vary due to missing reports or due to increased reporting frequency because of rapidly changing weather conditions. I want to make a column that is a moving average of the last 24 hours of temperature data. I have done so using the following array formula,

    {=AVERAGE(IF(A12685:A12856>(A12856-1),B12685:B12856, FALSE))}

    It works, but it seems clumsy and it is computationally expensive. Indeed, as the spreadsheet has grown quite large there is now a noticeable delay upon opening. I recently had two such spreadsheets open at the same time and things really bogged down.

    There must be a better way. The following will give me the value of the temperature that is 24 hours before the current time stamp (note: current time stamp in this example is at A12856).

    =VLOOKUP(A12856-1,A15:B12856,2)

    But what I need is the row number in which that temperature resides and some way to use that row number in an AVERAGE() function to average all temperatures from that row to the current row.

    Again, I’m seeking to replace the present array formula with a method that is less computationally expensive.

    Thanks for any help.
    Last edited by David4321; 01-23-2011 at 09:11 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Average 24 hours of data when sample rate fluctuates

    can you upload example?

  3. #3
    Registered User
    Join Date
    01-23-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2003 SP3
    Posts
    7

    Re: Average 24 hours of data when sample rate fluctuates

    OK here's a redacted version with a lot of extraneous data removed to get it under the 1MB upload limit.

    Whoops, I can't upload it for some reason. I get the following message:

    "Database error
    The Excel Help Forum database has encountered a problem."

    I clicked on the "paper clip" symbol, browsed to the file on my desktop, selected "open" and then "upload." That's when I got the above error.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Average 24 hours of data when sample rate fluctuates

    Maybe is too big... Try with smaller example (can't exceed 1MB).

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Average 24 hours of data when sample rate fluctuates

    Defining the rows via MATCHes and using a single AVERAGE wrapper will certainly be more efficient, as would a standard SUMIF/COUNTIF

    Please Login or Register  to view this content.
    edit: modified ranges per VLOOKUP rather than Array (ie 15:12856)
    Last edited by DonkeyOte; 01-23-2011 at 06:20 AM. Reason: typo

  6. #6
    Registered User
    Join Date
    01-23-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2003 SP3
    Posts
    7

    Re: Average 24 hours of data when sample rate fluctuates

    I already trimmed it down to 886 KB. OK, now I trimmed it down to 434KB.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-23-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2003 SP3
    Posts
    7

    Re: Average 24 hours of data when sample rate fluctuates

    Quote Originally Posted by DonkeyOte View Post
    Defining the rows via MATCHes and using a single AVERAGE wrapper will certainly be more efficient, as would a standard SUMIF/COUNTIF

    Please Login or Register  to view this content.
    Yes indeed, DonkeyOte, the code snippet looks good and the MATCH suggestion looks promising as well (I had to go into Excel help and look up "MATCH" to see what it does).

    I'm sure with this info I'll be able to improve the efficiency of the computations.

    Thanks,
    Last edited by DonkeyOte; 01-23-2011 at 06:37 AM.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Average 24 hours of data when sample rate fluctuates

    If as it seems you intend to repeat calculation for each row then for sake of efficiency I would suggest:

    Please Login or Register  to view this content.
    Calculation should prove virtually instantaneous

    The SUMIF/COUNTIF will be fast also but the above should prove quicker still.

  9. #9
    Registered User
    Join Date
    01-23-2011
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2003 SP3
    Posts
    7

    Re: Average 24 hours of data when sample rate fluctuates

    Thanks DonkeyOte. I'll have to wait until tomorrow to make the suggested changes but I'm sure it will work out well. If there are any snags I'll probably be able to work them through myself. Meantime, I'll mark this thread solved.

    Thanks again, DonkeyOte and all

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1