+ Reply to Thread
Results 1 to 9 of 9

Finding count of rows within time range

  1. #1
    Registered User
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Finding count of rows within time range

    Hi,
    I have a list of start and end times and I need to find for each start time, how many other start/end time rows contain this start time.

    Data looks like this:
    Start End
    15:22:35 15:22:40
    15:22:35 15:22:53
    15:22:37 15:22:50
    15:22:37 15:22:50
    15:22:38 15:22:43
    15:22:38 15:22:41
    15:22:38 15:22:41

    So you can see for the first row, 15:22:35 is within 2 start-end time ranges (itself and the next row).

    Is this possible in Excel please?
    Thanks

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Finding count of rows within time range

    COUNTIF will do what you need.

    =COUNTIF(A:A,A1)

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

    Re: Finding count of rows within time range

    Here, try this:

    =SUMPRODUCT(--($A$1:$A$100<=$A1),--($B$1:$B$100>=$A1))

    Assuming your data start at A1

  4. #4
    Registered User
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Finding count of rows within time range

    Quote Originally Posted by Whizbang View Post
    COUNTIF will do what you need.

    =COUNTIF(A:A,A1)
    Thanks for the prompt response, but this doesn't take into consideration the whole time range (start to end)

  5. #5
    Registered User
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Finding count of rows within time range

    Thanks - Sumproduct looks like it almost works, but I'm getting higher than possible values in some cells...
    Last edited by ChrisMu1; 05-01-2012 at 11:23 AM.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Finding count of rows within time range

    So is 15:22:37 within 4?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  7. #7
    Registered User
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Finding count of rows within time range

    Quote Originally Posted by ChemistB View Post
    So is 15:22:37 within 4?
    Yes.
    Actually looking at my data it may be an artifact of the timings only being to the nearest second.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Finding count of rows within time range

    The sumproduct formula seems to work. Gives 2 for first two rows, then 4 for next two, then 7 for last three. 15:22:38 is in the range of all seven rows. Yes?

  9. #9
    Registered User
    Join Date
    05-01-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Finding count of rows within time range

    Quote Originally Posted by ChemistB View Post
    The sumproduct formula seems to work. Gives 2 for first two rows, then 4 for next two, then 7 for last three. 15:22:38 is in the range of all seven rows. Yes?
    Yes I think that's it, thanks zbor!

+ 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