+ Reply to Thread
Results 1 to 5 of 5

Count max occurrences within rolling time frame

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question Count max occurrences within rolling time frame

    Hello!

    I'm working with a very large data set (>1m rows) of time card punches. The goal is to find out the maximum number of punches that occur within a given time frame.

    As an example, I want to find out the max number of punches within a ten minute time frame for the data below. The answer should come back as ten, for the time period between 13:25 and 13:34.

    This set spans over 20 stores and 6 months (with punches anywhere between 6am and 11pm). Any ideas how to iterate this? I realize I could create SUMIFS up against two columns of times (6:00, 6:01) and (6:10, 6:11) etc., but was hoping for a better solution that would allow me to change the range of time from ten minutes to five minutes or whatever else my boss would like to see.

    My data is simple, it's just two columns. I'm also posting a sheet (that has more and different info than below).

    Store Time
    29 3/23/14 12:57
    29 3/23/14 13:25
    29 3/23/14 13:25
    29 3/23/14 13:25
    29 3/23/14 13:25
    29 3/23/14 13:26
    29 3/23/14 13:26
    29 3/23/14 13:26
    29 3/23/14 13:26
    29 3/23/14 13:30
    29 3/23/14 13:30
    29 3/23/14 13:37
    29 3/23/14 13:37
    29 3/23/14 13:37
    29 3/23/14 13:37
    Attached Files Attached Files
    Last edited by timlat; 10-17-2014 at 05:29 PM.

  2. #2
    Registered User
    Join Date
    10-12-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Count max occurrences within rolling time frame

    I just wrote this, which is getting me there. Still not as iterative as I'd like.

    =COUNTIFS($B$2:$B$300,"<"&B2+$E$1,$B$2:$B$300,">"&B2-$E$1)

    With E1 being =10/(60*24) (to get the decimal amount that 10 minutes represents)
    Last edited by timlat; 10-17-2014 at 03:56 PM.

  3. #3
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: Count max occurrences within rolling time frame

    =(COUNTIF($B$2:$B$300,">="&E1)+COUNTIF($B$2:$B$300,"<="&E2))-ROWS(B2:B300)

    E1 and E2 are Start and End times
    If I've been of help, plz add reputation.

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

    Re: Count max occurrences within rolling time frame

    In E1, you can simply enter 0:05 and it understands that is 5 minutes.
    Since you are doing +/-, 0:05 represents 10 minutes, alternately, you could use 0:10 and in your formula, just use E1/2
    I dragged it down and your statement that 10 would be maximum seems incorrect.

    If you just want the maximum, you can enter this into a single cell (F1 for me) as an ARRAY formula
    =MAX(COUNTIFS($B$2:$B$300,"<"&(B2:B300)+$E$1,$B$2:$B$300,">"&(B2:B300)-$E$1))
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Attached Files Attached Files
    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

  5. #5
    Registered User
    Join Date
    10-12-2012
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Count max occurrences within rolling time frame

    ChemistB,

    Thanks for the insight here, and good catch at my inconsistency with the time frame I want to analyze.

    Now I just have to find a processor with enough power to run that array formula. It's hung now on only 30,000 rows (and I need it to do 900k).

    I appreciate the help!

+ 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] Count Rolling Year Occurrences
    By Scott_88 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-13-2014, 07:28 AM
  2. Count occurrences of value in a date range I can specify easily each time
    By mikalaka in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 07-14-2014, 07:14 PM
  3. Excel 2000 Count Entries within a time frame.
    By Daniel Salinas in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-10-2014, 12:10 PM
  4. Count time occurrences across multiple sheets
    By Lea724 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2011, 09:03 AM
  5. How do I count number of occurrences (dates) in a rolling year?
    By ShirleyTR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2005, 02: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