Closed Thread
Results 1 to 13 of 13

Count the number of consecutive occurrences

  1. #1
    Registered User
    Join Date
    03-12-2008
    Posts
    36

    Count the number of consecutive occurrences

    Hi,

    I have an excel spreadsheet to record employee holiday and sickness figures.

    It is set on as a grid e.g. column A stores all the dates and then employee names are used as column header.

    One of the triggers I need to use is where, an employee has been absent 28 consecutive days. When an employee is absent I simply enter 'ABSENT' against there name.

    Countif will count the number of time absent appears in the column however I need it to only recognise it if it is only 28 days in a row.

    Any help would be much appreciated!

    Thanks
    Last edited by NBVC; 11-19-2008 at 08:47 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try:

    Please Login or Register  to view this content.
    adjust ranges to suit... and confirm with CTRL+SHIFT+ENTER not just ENTER... you will see { } brackets appear around the formula.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Counting max consecutive occurrences of a string

    With
    A1: Dates
    A2:A50 contains dates
    B1 contains an employee name
    B2:B50 contains workday status values: IN, ABSENT, OFF, whatever

    This ARRAY FORMULA, committed with CTRL SHIFT ENTER
    (instead of just ENTER) counts the maximum consecutive
    occurrences of "ABSENT"
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Shamelessly poached:
    =MAX(FREQUENCY(IF(A1:A10="ABSENT",ROW(A1:A10)),IF(A1:A10<>"ABSENT",ROW(A1:A10))))
    Enter as array formula (Ctrl + Shift + Enter)


    http://www.ozgrid.com/forum/showthread.php?t=71645

    Domenic's post (#5)

    CC

  5. #5
    Registered User
    Join Date
    03-12-2008
    Posts
    36
    Hi Guys,

    Thanks for the quick response.

    I used NBVC's formula which has worked.

    Much appreciated.

  6. #6
    Registered User
    Join Date
    03-12-2008
    Posts
    36
    Hi,

    As I mentioned I have used NBVC's formula and it works to what I described, however I have realise that I had an oversight when describing what I required.

    An employee could be off 28 calendar days but only 16 of those days would be counted as working days because they work a 4 day week. If I was to enter the word "OFF" could the formula be amended to still count absent days consecuatively if the work "OFF occurs in between it?

    Sorry, thanks in advance!

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Count the number of consecutive occurrences

    Try this ARRAY FORMULA variation:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Last edited by Ron Coderre; 11-18-2008 at 12:40 PM.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by timmycl_7 View Post
    Hi,

    As I mentioned I have used NBVC's formula and it works to what I described, however I have realise that I had an oversight when describing what I required.

    An employee could be off 28 calendar days but only 16 of those days would be counted as working days because they work a 4 day week. If I was to enter the word "OFF" could the formula be amended to still count absent days consecuatively if the work "OFF occurs in between it?

    Sorry, thanks in advance!
    Try:
    Please Login or Register  to view this content.
    adjusting ranges again and confirming with CTRL+SHIFT+ENTER

  9. #9
    Registered User
    Join Date
    03-12-2008
    Posts
    36
    NBVC,

    Thanks for your help, I think I have got the formula working now. I used the first formula you gave me making some slight adjustments.

    Thanks

  10. #10
    Registered User
    Join Date
    11-09-2008
    Location
    South Africa
    Posts
    14

    Re: Count the number of consecutive occurrences

    Hi there!

    I don't know if you are still at this address but here's trying.

    Could you please forward me your spreadsheet and maybe just an explanation on how you use/d it? I have been tasked to look at absenteeism and using the Bradford Index although we are looking at a period of 26 weeks in which the absenteeism takes place and it seems what you did will help me a great deal.

    Thanking you in advance,
    Rennier
    South Africa

  11. #11
    Registered User
    Join Date
    04-11-2012
    Location
    Sierra Vista, AZ
    MS-Off Ver
    Excel 2003
    Posts
    4

    Question Re: Count the number of consecutive occurrences

    morning,

    I have a question that is somewhat related to the above. I have values in several columns, each value can only occur once per row. I'm trying to find out two things:
    1/ what is the longest consecutive occurrence by a particular value, say '23' within a certain date range;
    2/ what are the top 3 (or 5) consecutive occurrences by any value within the same date range.

    In other words, what I need to find out is this: 'the number 23 has occurred 7 times consecutively from 1-Mar-09 through whatever (dates are in the column A). And the longest consecutive occurrences have been made by numbers 'x', which has occurred so many times, from such and such date through such and such date. The next number that did this, was 'y', which occurred some many times, etc, etc.

    any help is appreciated,

    thanks,

    L

  12. #12
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Count the number of consecutive occurrences

    svako - do not exhume old ghost, err, posts... currently you can create a new thread at no charge, so why not make use of that opportunity and have a brand spanking new thread for yourself, instead of a hand-me-down!!!
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Count the number of consecutive occurrences

    Svako,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed 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