+ Reply to Thread
Results 1 to 10 of 10

COUNTIFS Between Date Range

  1. #1
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    COUNTIFS Between Date Range

    Hi All,

    So I have been working on quite an extensive formula and thanks to some help on here I was able to get the formula working as intended. However, I have now gotten an additional request to have the option to select a date range.

    My existing formula is:
    =COUNTIFS(data_source[Period],IF($S$1="-- Period --","<>",$S$1),data_source[Month],IF($S$2="-- Month --","<>",$S$2),data_source[Division],IF($C$3="-- Division --","*",$C$3),data_source[Cost Centre],IF($G$3="-- Cost Centre --","<>0",$G$3),data_source[Manager],IF($K$3="-- Manager --","*",$K$3),data_source[Job Description],IF($O$3="-- Job Description --","*",$O$3),data_source[Employment Type],IF($S$3="-- Employment Type --","*",$S$3),data_source[Gender],IF($C$4="-- Gender --","*",$C$4),data_source[Race],IF($G$4="-- Race --","*",$G$4),data_source[Age Group],IF($K$4="-- Age Group --","*",$K$4),data_source[Education Level],IF($O$4="-- Education Level --","*",$O$4),data_source[Service Years],IF($S$4="-- Service Years --","*",$S$4),data_source[Category 1 Q1.1],E$8)

    on the data_source[Month] criteria section I need to do an additional check, I need to see if a date range has been selected. I will be creating a second date field in V2. So if the user selects a date in S2 only values match S2 need to be returned. If, however the user selects a date in both S2 and V2 all values within the date range needs to be returned. This is what I've come up with thus far for the [Month] criteria part of the formula:

    data_source[Month],IF($V$2="-- Month --",IF($S$2="-- Month --","<>",$S$2),IF(AND(data_source[Month]>=$S$2,data_source[Month]<=$V$2),10,100))

    I'm not sure what to put where the 10 is and the 100 is.

    Here's the sample workbook

    http://www.excelforum.com/attachment...oard_v1.0.xlsx

    Thanks
    Last edited by SalientAnimal; 10-30-2014 at 04:24 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,064

    Re: COUNTIFS Between Date Range

    OMG!!!

    Considerable respect to anyone who sorts this one out without seeing the formula in context (in an Excel sheet posted on the Forum).
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: Lá fhéile Pádraig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    Re: COUNTIFS Between Date Range

    Sample workbook, how ever this formula is not in the sample workbook as it was in the original post:
    http://www.excelforum.com/attachment...oard_v1.0.xlsx

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: COUNTIFS Between Date Range

    wow that is going to take some figuring out

    I think, I would add a few (?) helper columns on your data sheet and combine records there. That way, you can probably significantly reduce all those IF's by referencing the helper, instead of all teh various cells
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    Re: COUNTIFS Between Date Range

    The main formula does look rather complicated, but that's mainly because of the COUNTIFS criteria. I'm just not sure if the way I am trying to add a lookup of between two dates is correct or not. I need some help on doing that, and know that the way I have tried to do it is wrong.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,064

    Re: COUNTIFS Between Date Range

    the normal format for countifs between dates is:

    =COUNTIFS(Data range,">="&Cell containing start date,Data range,"<="&Cell containing end date)

    e.g.

    =COUNTIFS(A1:A100,">="&B1,A1:A100,"<="&B2)

    not sure if this helps...

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: COUNTIFS Between Date Range

    Have you given any consideration to adding helper columns, to simplify those monsters?

    Another option might be to use Pivot Tables here?

  8. #8
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    Re: COUNTIFS Between Date Range

    I like the solution you have provided Glenn, but I don't think it will work in my scenario. The reason I say this is because my dates are looking at a range of dates after converting it to a number.

    Basically I am only extracting the month number and not the full date.

  9. #9
    Forum Contributor
    Join Date
    12-24-2010
    Location
    South Africa
    MS-Off Ver
    Office 2003; Office 2007; Office 2010 (Prefered)
    Posts
    102

    Re: COUNTIFS Between Date Range

    FDibbins, what helper columns would you recommend? And how should I use these?

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: COUNTIFS Between Date Range

    Am I missing something - I can't see Period or Month columns in your table?
    Remember what the dormouse said
    Feed your head

+ 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: 2
    Last Post: 05-28-2014, 06:52 AM
  2. [SOLVED] COUNTIFS With Date Range
    By OlYeller21 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-03-2013, 08:32 AM
  3. [SOLVED] COUNTIFS with Date Range
    By whizbee in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 10-28-2013, 03:44 PM
  4. Using countifs with date range, and summing values in that range
    By bmcoonan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-30-2013, 11:28 AM
  5. date range and COUNTIFS
    By momus12 in forum Excel General
    Replies: 8
    Last Post: 12-28-2008, 05:38 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