+ Reply to Thread
Results 1 to 15 of 15

average time based on clock time range

  1. #1
    Registered User
    Join Date
    07-11-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    24

    average time based on clock time range

    I would like to average clock times that fall within a specific time frame.

    I have already calculated an elapsed time with a formula but want to find the average time between 8:00 and 20:00 and between 20:01 and 7:59.
    Any ideas?

    Thanks in advance

    Performed time Ordered to radiology report (min)
    7:20 37
    8:59 61
    14:24 99
    17:34 105
    17:47 939
    19:19 77
    22:46 52
    22:48 66
    23:06 47
    Last edited by xrayexceller; 07-23-2013 at 06:08 PM.

  2. #2
    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,946

    Re: average time based on clock time range

    this will work for the 1st part...
    =AVERAGEIFS(B1:B9,A1:A9,">="&8/24,A1:A9,"<="&20/24)

    Tring to figure out why the opposite wont work...
    =AVERAGEIFS(B1:B9,A1:A9,"<"&8/24,A1:A9,">"&20/24)
    gives #DIV/0
    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

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: average time based on clock time range

    Quote Originally Posted by FDibbins View Post
    Tring to figure out why the opposite wont work...
    =AVERAGEIFS(B1:B9,A1:A9,"<"&8/24,A1:A9,">"&20/24)
    gives #DIV/0
    The time can not be both <8:00 AM and >8:00 PM at the same time because the clock rolls over to 0 at midnight.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    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,946

    Re: average time based on clock time range

    @ Tony...OK I can see that, but if I change that to...
    =AND(A1<8/24,A1>20/24)
    copied down, I get TRUE's where I should, and FALSE's where I should? (and swapping that 1, swaps the T/F's around too)

    So what would you suggest for this?

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: average time based on clock time range

    Quote Originally Posted by FDibbins View Post
    ...=AND(A1<8/24,A1>20/24)......I get TRUE's where I should, and FALSE's where I should.....
    Are you sure? That formula will always return FALSE no matter what the value of A1, you'd need OR in place of AND to get correct results...

    Quote Originally Posted by FDibbins View Post
    So what would you suggest for this?
    If you use the above formula with OR then you can use AVERAGEIF based on the heplper column...... or without a helper you can use an array formula like

    =AVERAGE(IF((A1:A9<8/24)+(A1:A9>20/24),B1:B9))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: average time based on clock time range

    Data in the range A1:B9

    D1 = 20:01
    E1 = 7:59

    Then, this array formula**:

    =AVERAGE(IF((A1:A9>=D1)+(A1:A9<=E1),B1:B9))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  7. #7
    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,946

    Re: average time based on clock time range

    Sorry guys, my bad, I actually did mean to type OR

    Thanks for the assist

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: average time based on clock time range

    ..........

  9. #9
    Registered User
    Join Date
    07-11-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: average time based on clock time range

    Thanks for this. I modified the above formula to work with my spreadsheet and it worked as set
    {=AVERAGE(IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454))}
    but I would like to find the average for a filtered list, stat vs routine study type. Can this be done?

  10. #10
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: average time based on clock time range

    Does the word Stat or Routine Study exist in the rows?

    You could add an additional IF condition

    {=AVERAGE(IF(range of rows with Stat and Routine="Stat",IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454)))}

    or

    {=AVERAGE(IF(range of rows with Stat and Routine="Routine Study",IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454)))}

  11. #11
    Registered User
    Join Date
    07-11-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: average time based on clock time range

    Yes but in column B

  12. #12
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: average time based on clock time range

    {=AVERAGE(IF($B$1:$B$454="Stat",IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454)))}

    or

    {=AVERAGE(IF($B$1:$B$454="Routine Study",IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454)))}

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: average time based on clock time range

    Quote Originally Posted by xrayexceller View Post
    Thanks for this. I modified the above formula to work with my spreadsheet and it worked as set
    {=AVERAGE(IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454))}
    but I would like to find the average for a filtered list, stat vs routine study type. Can this be done?
    If I understand what you want to do, try this.

    Assuming B5:B454 contains "stat" or "routine study".

    This array formula**:

    =AVERAGE(IF(SUBTOTAL(3,OFFSET(B5,ROW(B5:B454)-ROW(B5),0,1)),IF((E5:E454<8/24)+(E5:E454>20/24),Q5:Q454)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    If that isn't what you had in mind can you post a SMALL sample file that shows us what result you expect?

    SMALL = about 20 rows worth of data

  14. #14
    Registered User
    Join Date
    07-11-2013
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: average time based on clock time range

    Thanks, that did the trick.

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: average time based on clock time range

    Can't tell who you're replying to so I'll just say this...

    You're welcome. We appreciate the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Split Shift & Time Managment Grid based on 24 hour clock in 15 min increments
    By paxile2k in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-18-2013, 08:23 PM
  2. Average of time range
    By DexterG in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2012, 08:20 AM
  3. Replies: 3
    Last Post: 09-29-2007, 04:58 PM
  4. [SOLVED] How do I add a duration time value and a clock time value?
    By sueb262 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2006, 05:45 PM
  5. [SOLVED] can cell's act like time clock at a certen time/date for payments
    By Colin2u in forum Excel General
    Replies: 6
    Last Post: 08-04-2005, 08:05 PM

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