+ Reply to Thread
Results 1 to 8 of 8

Count consecutive dates as one

Hybrid View

squirrellydw Count consecutive dates as one 04-03-2015, 09:09 AM
Bernie Deitrick Re: Count consecutive dates... 04-03-2015, 09:32 AM
squirrellydw Re: Count consecutive dates... 04-03-2015, 09:38 AM
Bernie Deitrick Re: Count consecutive dates... 04-03-2015, 09:44 AM
newdoverman Re: Count consecutive dates... 04-03-2015, 02:18 PM
squirrellydw Re: Count consecutive dates... 04-03-2015, 06:11 PM
mkesalmon Re: Count consecutive dates... 04-06-2017, 05:27 PM
Bernie Deitrick Re: Count consecutive dates... 04-06-2017, 05:48 PM
  1. #1
    Registered User
    Join Date
    04-03-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    12

    Count consecutive dates as one

    Hi all, first post here but I have used the site many time to find answers. Now I have a few myself.
    I’m working on a spreadsheet for work and I have a few things I can’t figure out.

    I need to track when employees take off sick, vacation, etc.

    I enter dates in column C starting on row 82 and and I use a code from a pull down menu to track the type of leave they use. This code is entered in column H row 82. The code for sick leave is "*02" The issue I'm having is if the employee calls in sick two days or more in a row I want that to only count as one occurrence.

    So right now if I track sick leave and they call in sick on 3 different dates in a year it counts it as 3 times. For example they call in sick on 2/3/2014, 4/4/2014 and 1/21/2015. However if they call in sick again on 1/22/2015 it counts it as 4 times. What I would like is if the dates are together to count it as 1 occurrence, so still only count as being sick 3 times. So separate dates 2/3/2014 and 4/4/2014 as 2 occurrence and dates together 1/21/2015 and 1/22/2015 as 1 occurrence. Any idea how I would do this?

    The other thing I would like to do is be able to track this in a rolling year. For example I enter the date of the last time they called in sick and go back one year from that date to see how many times they called in sick or used vacation etc.


    Thanks for any help you can give me.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,288

    Re: Count consecutive dates as one

    =SUM(IF(RIGHT($H$82:$H$300,2)="02",IF(RIGHT($H$83:$H$301,2)<>"02",1,0),0))

    Note the one cell offset of the two ranges. Enter this by pressing CTRL+SHIFT+ENTER to activate the array formula, not just ENTER. You will know the formula is correct 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, and if you ever edit the formula, you need to array-enter it again.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    04-03-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    12

    Re: Count consecutive dates as one

    I just tested this out and I guess it can't work if the cells are merged? Where I enter the dates it actually cells C and D. I can probably change that, it will just not look as nice.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,288

    Re: Count consecutive dates as one

    It doe not care about the dates, just the codes in H. "This code is entered in column H row 82"

    And it does not care about merged cells - just reference the left column of the merge, and you should be OK.

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Count consecutive dates as one

    This solution takes into consideration the dates in column C and the codes in column H. This allows you to use different codes for different leave types even if they are on consecutive dates.

    Formula: copy to clipboard
    =IFERROR(IF(OR(C2="",H2=""),"",IF(AND(C2=C1+1,H2=H1),"",1)),1)
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  6. #6
    Registered User
    Join Date
    04-03-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    12

    Re: Count consecutive dates as one

    Thak you for all the help Bernie, you are awesome

  7. #7
    Registered User
    Join Date
    03-24-2017
    Location
    Madison, Wisconsin
    MS-Off Ver
    2010
    Posts
    2

    Re: Count consecutive dates as one

    I'm trying to setup a similar type tool. I've got a database of call logs that I need to count based on the employee ID(primary key) then date and only within the last 12 weeks. Its currently setup to countifs the ID then the date within a defined range. I need it to still do this but count consecutive dates as 1 occurrence.

    Any ideas would be helpful.

  8. #8
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,288

    Re: Count consecutive dates as one

    Use a column of formulas that flags any date/ID combo that occurs in the last day (or doesn't occur) and use that as a filter.

+ 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. Replies: 17
    Last Post: 02-14-2024, 07:07 AM
  2. Count of consecutive dates as single occasion per patient
    By mallen91693 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-04-2014, 01:32 AM
  3. Replies: 3
    Last Post: 02-16-2012, 01:51 PM
  4. Replies: 3
    Last Post: 02-14-2012, 01:38 AM
  5. [SOLVED] Count consecutive dates only
    By mjbuhr@umich.edu in forum Excel General
    Replies: 0
    Last Post: 05-04-2006, 11:10 AM

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