+ Reply to Thread
Results 1 to 9 of 9

COUNTIFS DATE does not work

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    5

    Smile COUNTIFS DATE does not work

    Hi everyone,

    I have this Formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    YTD_CM!B:B,B$3, = Looking for Name
    YTD_CM!G:G,DATE(2013,,) = should look for everything with a date of 2013 - But it is not working

    What I'm actually looking for at DATE(2013,,) is:

    Result: Today Yesterday current month to date (MTD) current year to date (YTD)
    Formula: =Today() =Today()-1 No idea No idea


    If I could go wild I would like to have working something like this
    • DATE(current year,,)
    • DATE(current year,current month,)
    • DATE(current year,current month,current day)
    • DATE(current year,current month,current day-1)

    I can't seem to find the answer, today just wont work.

    Any Help appreciated,

    Thank you.

    Rene

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: COUNTIFS DATE does not work

    The criteria for you second check is not truly a criteria. Excel does not know if you are looking for something equal to, less than, greater than, or not equal to. This is a way to do a range for 2013 dates:
    =COUNTIFS(L2:L31,"<1/1/2014",L2:L31,">12/31/2012")

    You can use a similar method for the month check.

    For the specific days, you should be able to use just the check for TODAY() or TODAY()-1
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: COUNTIFS DATE does not work

    You might be better using SUMPRODUCT ...

    Total amounts in column B for dates in column A in 2012:

    =SUMPRODUCT(--(B$2:$B$31), --(YEAR($A$2:$A$31)=2012))

    Total amounts in column B for dates in column A in 2012 and month of November:

    =SUMPRODUCT(--(B$2:$B$31), --(YEAR($A$2:$A$31)=2012),--(MONTH($A$2:$A$31)=11))

    Year to date:

    =SUMPRODUCT(--(B$2:$B$31),--(YEAR($A$2:$A$31)=YEAR(TODAY())))

    Current month to date:

    =SUMPRODUCT(--(B$2:$B$31),--(YEAR($A$2:$A$31)=YEAR(TODAY())),--(MONTH($A$2:$A$31)=MONTH(TODAY())))


    It's usually easier for everyone if you provide a sample workbook. Then we can see your data and the workbook structure.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: COUNTIFS DATE does not work

    hi Rene, welcome to the forum. you could consider SUMPRODUCT
    current year
    =SUMPRODUCT((YTD_CM!B:B=B$3)*(TEXT(YTD_CM!G:G,"yyy")=TEXT(TODAY(),"yyy")))

    current year, current month
    =SUMPRODUCT((YTD_CM!B:B=B$3)*(TEXT(YTD_CM!G:G,"yyym")=TEXT(TODAY(),"yyym")))

    today
    =SUMPRODUCT((YTD_CM!B:B=B$3)*(YTD_CM!G:G=TODAY()))

    yesterday
    =SUMPRODUCT((YTD_CM!B:B=B$3)*(YTD_CM!G:G=TODAY()-1))

    COUNTIFS can also do it. formula's a little longer but works faster:
    =COUNTIFS(YTD_CM!B:B,B$3,YTD_CM!G:G,">="&DATE(YEAR(TODAY()),1,1),YTD_CM!G:G,"<="&DATE(YEAR(TODAY()),12,31))
    =COUNTIFS(YTD_CM!B:B,B$3,YTD_CM!G:G,">="&EOMONTH(TODAY(),-1)+1,YTD_CM!G:G,"<="&EOMONTH(TODAY(),0))
    you should get the drift

    i do not recommend ranging the whole columns though. slows down Excel. use a big range you wont use up instead. like "YTD_CM!B2:B1000"

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    Registered User
    Join Date
    02-19-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: COUNTIFS DATE does not work

    Dear benishiryo, TMShucks and Pauleyb,

    Thanks so much for your help, I will now go through everything in detail and come back to you, and of course if it's still open I'm going to provide an example workbook.

    Thanks a lot, very much appreciated!

    Rene

    ---

    Update: I've found a reason why today() is not working for me, my date contains the Time too.

    Since it got to complicated to explain I also added an Sample File

    1Forum_Sample_ReneHelp.xlsx

    could one of you have a look?

    FYI - I cannot change the Source Data, this comes from an external Database I can only add formulas (like I did with the Red Text).

    Again, Thanks a lot for your help.

    Cheers,
    Rene
    Last edited by ReneHelp; 02-19-2013 at 02:23 PM. Reason: Update

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: COUNTIFS DATE does not work

    you're very welcome. try this:
    =SUMPRODUCT((YTD_CM!B:B=B$3)*(TEXT(YTD_CM!G:G,"yyymd")=TEXT(TODAY(),"yyymd")))

  7. #7
    Registered User
    Join Date
    02-19-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: COUNTIFS DATE does not work

    Quote Originally Posted by benishiryo View Post
    you're very welcome. try this:
    =SUMPRODUCT((YTD_CM!B:B=B$3)*(TEXT(YTD_CM!G:G,"yyymd")=TEXT(TODAY(),"yyymd")))
    Hi benishiryo,

    thanks, this did the job. But it occurred a new problem, this now seems to use so much performance, it almost freezes my pc and I can literally watch how excel calculates every single cell. You wrote earlier countifs would be better, can you have a look at my file or at these Formulas. I've also added a 3 Argument, to look for a Campaign Name. The Result is correct, it just works very slow, and I have to make this for much more data then just the 3 sample campaigns.

    Also how can I use it to count "Last Month" results today()-30 is most probably wrong.

    Open In Progress Closed Today Closed Yesterday Closed MTD Closed YTD Closed Last Month
    =SUM(COUNTIFS(YTD_CM!$D:$D,"Open",YTD_CM!$M:$M,$A11,YTD_CM!$B:$B,B$3)) =SUM(COUNTIFS(YTD_CM!$C:$C,"In Progress",YTD_CM!$M:$M,$A11,YTD_CM!$B:$B,B$3)) =SUMPRODUCT((YTD_CM!$B:$B=B$3)*(YTD_CM!$M:$M=$A11)*(TEXT(YTD_CM!$G:$G,"yyymd")=TEXT(TODAY(),"yyymd"))) =SUMPRODUCT((YTD_CM!$B:$B=B$3)*(YTD_CM!$M:$M=$A11)*(TEXT(YTD_CM!$G:$G,"yyymd")=TEXT(TODAY()-1,"yyymd"))) =SUMPRODUCT((YTD_CM!$B:$B=B$3)*(YTD_CM!$M:$M=$A11)*(TEXT(YTD_CM!$G:$G,"yyym")=TEXT(TODAY(),"yyym"))) =SUMPRODUCT((YTD_CM!$B:$B=B$3)*(YTD_CM!$M:$M=$A11)*(TEXT(YTD_CM!$G:$G,"yyy")=TEXT(TODAY(),"yyy")))

    2Forum_Sample_ReneHelp.xlsx

    Thanks again for your Help!

    Rene

  8. #8
    Registered User
    Join Date
    02-19-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: COUNTIFS DATE does not work

    A very big thank you to benishiryo
    who helped me the last couple days to solve my Probelm.

    Very nice Person, thanks to everyone!

    Problem solved!

  9. #9
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: COUNTIFS DATE does not work

    basically what i suggested to Rene was:
    - COUNTIFS instead of SUMPRODUCT to calculate faster
    - not range up the whole column
    - consider timing in the calculation

    so to calculate yesterday, here's my solution:
    =COUNTIFS(YTD_CM!B$1:B$10000,B$3,YTD_CM!G$1:G$10000,">="&TODAY()-1,YTD_CM!G$1:G$10000,"<"&TODAY())

+ 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