+ Reply to Thread
Results 1 to 12 of 12

Trouble with COUNTIFS() formula

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Trouble with COUNTIFS() formula

    I have a table that is formatted as so:

    PHP Code: 
        A           B                  C                     D
    1 Type    Timeinitial    Time ending           Total Time    
    2   8                                                  00
    :00            
    3   8                                                 00
    :00            
    4   5    7
    /29/2012 8:37    7/29/2012 8:55            00:18    
    5   5    8
    /4/2012 12:57    8/4/2012 13:06             00:09 
    There are a lot more rows below Row 5....

    I am trying to count each row where Type = 5, the total time is >00:00 and the month is August

    I wrote the following formula:

    =COUNTIFS(A2:A5, "5",D2:D5, ">00:00",C2:C5="mmmyyyy", "Aug2012")

    I keep getting a num error...any help of this formulate is deeply appreciated!
    Last edited by neoshaakti; 08-19-2013 at 08:53 PM.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trouble with COUNTIFS() formula

    Try it like this...

    =SUMPRODUCT(--(A2:A5=5),--(D2:D5>0),--(TEXT(C2:C5,"mmmyyyy")="Aug2012"))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    08-08-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: Trouble with COUNTIFS() formula

    Thanks for the suggestion Tony Valko...unfortunately that formula throws an Error in Value....

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trouble with COUNTIFS() formula

    Based on the posted sample data I get the correct result of 1.

    Post the exact formula that you are using.

  5. #5
    Registered User
    Join Date
    08-08-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: Trouble with COUNTIFS() formula

    =SUMPRODUCT(--('Raw data'!D3:D339=2),--('Raw data'!AB2:AB339>0),--(TEXT('Raw data'!M2:M339,"mmmyyyy")="Aug2012"))


    Thanks

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trouble with COUNTIFS() formula

    All of the ranges need to be the same size.

    Column D starts on row 3, D3, while columns AB and M start on row 2, AB2 and M2.

  7. #7
    Registered User
    Join Date
    08-08-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: Trouble with COUNTIFS() formula

    Thank you, I can;t believe I missed that

    What seems to always trip me up is this statement: =TEXT(C2:C5,"mmmyyyy")="Aug2012"))

    because I know that excel asks for value and format_text as so:

    text(value,format_text)

    How does (TEXT(C2:C5,"mmmyyyy")="Aug2012")) fit into the formula above?

    Thank you

  8. #8
    Registered User
    Join Date
    08-08-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: Trouble with COUNTIFS() formula

    Also, what was wrong with my original formula?
    =COUNTIFS(A2:A5, "5",D2:D5, ">00:00",C2:C5="mmmyyyy", "Aug2012")


    Thanks a bunch!

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trouble with COUNTIFS() formula

    --(TEXT(C2:C5,"mmmyyyy")="Aug2012")

    That's testng to see if the dates in column C, when formatted as text strings in the format mmmyyyy (short month name followed by the 4 digit year number), equal the text string Aug2012.

    Examples:

    C4 = 7/29/2012 8:55 = (TEXT(C4,"mmmyyyy") = Jul2012
    C5 = 8/4/2012 13:06 = (TEXT(C5,"mmmyyyy") = Aug2012

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trouble with COUNTIFS() formula

    It was OK up to this point:

    =COUNTIFS(A2:A5, "5",D2:D5, ">00:00",...

    The COUNTIFS function can only do straight comparisons. It can not take arguments that "manipulate" the range references which is what (TEXT(C2:C5,"mmmyyyy")="Aug2012") does.

  11. #11
    Registered User
    Join Date
    08-08-2013
    Location
    Jersey
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: Trouble with COUNTIFS() formula

    Thanks Tony, I appreciate the help

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trouble with COUNTIFS() formula

    You're welcome. Thanks for the feedback!

+ 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. COUNTIFS OR...multiple countifs without duplication in the numbers
    By HooligaD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2012, 09:53 AM
  2. [SOLVED] Countifs formula
    By lorber123 in forum Excel General
    Replies: 2
    Last Post: 09-25-2012, 12:44 PM
  3. Excel 2007 : Trouble with Countifs
    By jayres14 in forum Excel General
    Replies: 3
    Last Post: 03-09-2012, 09:51 AM
  4. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  5. Excel 2007 : COUNTIFS Formula
    By jhg1226 in forum Excel General
    Replies: 4
    Last Post: 05-02-2010, 11:40 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