+ Reply to Thread
Results 1 to 2 of 2

Match Value and AVERAGE Time Before/After Midnight

  1. #1
    Registered User
    Join Date
    07-22-2011
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    4

    Match Value and AVERAGE Time Before/After Midnight

    I'm at my wits end and hope someone can help. I have two formulas that work, but I need to combine them and don't know how.

    Sample Data:
    A B C D
    1 NAME START END
    2 JOHN 23:49:11 01:32:09
    3 MARY 00:28:28 02:12:47
    4 ROBERT 00:27:26 02:16:14
    5 ROBERT 22:49:22 23:38:45
    6 MARY 23:14:26 00:15:57
    7 JOHN 23:52:44 01:27:32
    8 ROBERT 23:33:27 01:21:34
    9 MARY 01:37:59 03:33:37
    10 JOHN 00:50:59 02:37:30

    I need to calculate the average START and END times for each person, which I can do by entering =AVERAGE(IF($A$2:$A$10=$A2,$B$2:$B$10)) as an array formula. The problem is that because both the start and end times are sometimes before midnight and sometimes after, the result is incorrect. (This formula returns the average of JOHN's START times as 16:10:58.)

    I can generate the correct START time average for John by entering =MOD(AVERAGE(IF(B2:B4<=TIME(2,0,0),1+B2:B4,B2:B4)),1), also as an array formula. This provides the correct result of 00:10:58.

    What I need to do is combine both of these. I've tried =MOD(AVERAGE(IF(AND(A2:A10=A2,B2:B10<=TIME(2,0,0)),1+B2:B10,B2:B10)),1) but the results are all wrong. For John, it returns 13:24:54.

    I'm attaching a workbook with the sample data - I hope someone can make sense of this. Thanks so much!
    Attached Files Attached Files
    Last edited by 4lilprinces; 08-29-2013 at 03:50 PM. Reason: edited for clarity

  2. #2
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Match Value and AVERAGE Time Before/After Midnight

    I'm no expert in arrays, but you could use this idea to calculate the right time difference per row:

    =IF C2>D2, calculate 24:00:00 - C2 + D2

    maybe that can get you started
    When I say semicolon, u say comma!

+ 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. time value after midnight
    By michelindb in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-12-2013, 03:24 PM
  2. Average Time Across Midnight
    By Banttari in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-18-2013, 11:38 AM
  3. Calculating work time when end time is after midnight.
    By dpatchie in forum Excel General
    Replies: 1
    Last Post: 02-01-2012, 11:10 AM
  4. Replies: 4
    Last Post: 01-11-2012, 07:59 PM
  5. Midnight as TIME()
    By ZooTV92 in forum Excel General
    Replies: 8
    Last Post: 07-03-2011, 08:38 AM

Tags for this Thread

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