+ Reply to Thread
Results 1 to 13 of 13

Countif criteria date range in same column

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Countif criteria date range in same column

    I want to use countif function to count the number of dates that fall in the given range.

    24-Jul-12
    19-May-10
    19-May-10
    8-Aug-12
    15-Jan-11
    15-Jan-11
    5-Jul-12
    18-Nov-10
    2-Dec-10
    16-Jul-12
    25-Jul-12
    16-Jul-12
    19-May-10
    12-Jul-12
    12-Jul-12
    2-Aug-10
    5-Jul-12
    18-Nov-10
    2-Dec-10
    16-Jul-12
    25-Jul-12
    16-Jul-12
    19-May-10
    12-Jul-12
    12-Jul-12
    2-Aug-10
    2-Aug-10
    7-Feb-12
    19-May-10
    19-May-10
    26-Jan-12
    1-Jul-10
    4-Sep-12
    19-May-10
    25-Jun-12
    19-May-10
    28-Jun-12
    1-Jul-10
    15-Jan-11

    =sum(COUNTIF(C:C,"<"&DATEVALUE("8/1/2012"),">"datevalue("8/1/10")

    the same format works when I use it with multiple text criteria ( which i discovered in this forum :-)), howver for some reason it gives an error with the date function.

    I would not prefer to use the suproduct function as it is a volatile function.

    The only option i can think of is to use the same range twice.
    =SUM(COUNTIFS(C:C,"<"&DATEVALUE("8/1/2012"),C:C,">"&DATEVALUE("8/1/10")))

    Any thoughts / suggestions on why the function will not work with 2 date criteria. Appreciate the help.

    thanks

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif criteria date range in same column

    See the file.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Countif criteria date range in same column

    Thanks Oeldere. However, i was hoping to refer to the column only once.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif criteria date range in same column

    I added the cells B1 and C1 to make the solution more flexibel.

    What do you mean with refer to the column only once?

  5. #5
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Countif criteria date range in same column

    =sum(COUNTIFS($A$1:$A$39,(">="&$B$1,"<="&$C$1)))
    here's how i want the formula to work but it does not

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif criteria date range in same column

    1) And what is the answer of your formula?

    2) Why do you want to sum the value?

  7. #7
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Countif criteria date range in same column

    Sorry for responding so late.
    I do not get an answer to the formula that I typed and I would like to find out the reason. The function works if I had 2 text criteria instead of a date criteria.
    normally the sum function is used with the countif function when you have multiple criteria for the same column as is in this case.

    thanks

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

    Re: Countif criteria date range in same column

    I don't think it can be done. Why don't you name the range something short (drng or something). That would make things easier.
    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

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

    Re: Countif criteria date range in same column

    with text criteria, you are not using ">" or "<" operators; you are just using implicit "=" operator within an "array constant", with the following construct:

    =sum(countif(a:a,{"first_criterion","second_criterion"}))

    the operating phrase here is "array constant", which does not allow for any ">" / "<" / "=" operator to be included within the flower / curly brackets.

    you cannot extrapolate constructs for alphabetical operations onto those requiring numerical calculations directly all the time (or vice versa); this is one of those cases.
    Last edited by icestationzbra; 10-20-2012 at 11:34 PM.
    - 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 -

  10. #10
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Countif criteria date range in same column

    Thanks. That makes lot more sense.
    I learnt something new about the array constant. I will be careful about extending the logic from alphabetical operation to a numeric one or vice versa the next time.
    Is there a way in excel that one could possibly write multiple criteria {< datevalue("12/10/12"); > datevlaue("11/12/12")}referencing the same column, in instances like these if one has to count the date values falling in a given range.

    Thanks

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

    Re: Countif criteria date range in same column

    by the way, SUMPRODUCT is NOT a volatile function; it is an implicit "array" function that is slow because of that reason, that's all.

  12. #12
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Countif criteria date range in same column

    Ok.. thanks for the input. I had read on chandoos forum that sumproduct is a volatile function. since the function is so slow, i assumed that to be true. Thanks for clearing that up.

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

    Re: Countif criteria date range in same column

    well, for the example you quoted, previous suggestions of SUMPRODUCT or COUNTIFS would be the way to go; you would need to reference the column in question multiple times, and you cannot use the "array" braces.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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