+ Reply to Thread
Results 1 to 9 of 9

Calculating Averages Over a Time Range

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    11

    Calculating Averages Over a Time Range

    I have two tables - one where the first column is days and the second column is a list of pressure readings from those days. The second table's first column represents the beginning of a list of time ranges and the second column represents the end of those time ranges. I need to find the average of the pressure data over the range indicated by those columns. I have WAY too much data to do this manually - I need a function that pulls the start and end date from my spreadsheet and does all the calculation and referencing for me.

    Below is an example spreadsheet.

    The pressure data is on a table that looks like this.
    Day Pressure
    1 8000
    2 9000
    3 8500
    4 9500

    And the second table looks like this. The AVERAGE() functions in the third column are what it would be if I just input what I wanted manually - the spreadsheet needs to figure out what range to average on its own. What would I want to input to get these averages?

    Start Day End Day Average Pressure
    1 3 AVERAGE(B2:B4)
    1 2 AVERAGE(B2:B3)
    2 4 AVERAGE(B3:B5)
    3 4 AVERAGE(B4:B5)
    1 4 AVERAGE(B2:B5)

    Any help with this would be appreciated. I have tried using combinations of the AVERAGE() and IF() functions as well as AVERAGE() with INDEX() but have had no success yet.

    Thanks in advance for the help!
    Last edited by adm0104; 06-10-2013 at 12:09 PM.

  2. #2
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    245

    Re: Calculating Averages Over a Time Range

    You should be able to use the OFFSET function combined with AVERAGE. If you'd like more specific help setting the formula up, please upload a sample spreadsheet.
    <--- If you like the answer, press *.

  3. #3
    Registered User
    Join Date
    06-06-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Calculating Averages Over a Time Range

    Here is an example workbook. It's in Excel format right now - if you would prefer that I attach it as a jpeg or other image format just say so.

    Example Workbook.xlsx

  4. #4
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    245

    Re: Calculating Averages Over a Time Range

    In F5 you can use

    =AVERAGE(OFFSET($A$4,D5,1,E5-D5+1,1))

    and drag down through all the yellow cells.

    This formula will ONLY WORK IF your days are always in order like they are in your example, with no days skipped. If that might not be the case, we can probably modify the formula, but I'd rather not make it more complicated than it needs to be.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Calculating Averages Over a Time Range

    Or you could use the built-in averageifS() function...
    =AVERAGEIFS($B$5:$B$19,$A$5:$A$19,">="&D5,$A$5:$A$19,"<="&E5)
    This will work for any dates between those values
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    245

    Re: Calculating Averages Over a Time Range

    Good one, I should've thought of that! I was making it more complicated than it needs to be!

  7. #7
    Registered User
    Join Date
    06-06-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Calculating Averages Over a Time Range

    The AVERAGEIFS() solution works perfectly.

    Thanks a lot!

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Calculating Averages Over a Time Range

    Happy to help and thanks for the feedback

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Calculating Averages Over a Time Range

    This might work for you.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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