+ Reply to Thread
Results 1 to 21 of 21

COUNTIF Formula help

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    74

    COUNTIF Formula help

    I have a table with an array of data, rows S, T, U, V and W all contain numbers.

    I need a formula that will count how many times in my table, that the value of these 5 columns in any given row is Zero.
    If S2, T2, U2, V2, and W2 all sum to Zero, I need the formula to count that

    There are over 10,000 rows and the number varies everyday, it could be anywhere between 10,000 and 14,000.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: COUNTIF Formula help

    Do you mean?

    =COUNTIF(S2:W1000,0)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    06-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: COUNTIF Formula help

    Quote Originally Posted by Fotis1991 View Post
    Do you mean?

    =COUNTIF(S2:W1000,0)
    That doesn't work because that just counts the total number of zeros in the columns.

    I need it only to recognize when S2=0 T2=0 U2=0 V2=0 and W2=0

    If any of those value are greater than zero then do not count it, so if S2=5 T2=0 U2=0 V2=0 and W2=0, then that row should not be counted

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: COUNTIF Formula help

    Try

    =SUMPRODUCT(--(S2:S1000* T2:T1000* U2:U1000* V2:V1000* W2:W1000>0)

    But this will also blank calculate as 0. Si that OK?

  5. #5
    Registered User
    Join Date
    08-17-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    82

    Re: COUNTIF Formula help

    Helllo,

    I think you could use for example the following formula:

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: COUNTIF Formula help

    Hi FCarv, no that won't help.
    Each of criteria (S2=0, T2=0 etc) will return you TRUE or FALSE.
    So you will basically count TRUE and FALSE in range and then sum it...

  7. #7
    Registered User
    Join Date
    06-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: COUNTIF Formula help

    Quote Originally Posted by zbor View Post
    Try

    =SUMPRODUCT(--(S2:S1000* T2:T1000* U2:U1000* V2:V1000* W2:W1000>0)

    But this will also blank calculate as 0. Si that OK?
    This didn't work either, not having any luck

  8. #8
    Registered User
    Join Date
    08-17-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    82

    Re: COUNTIF Formula help

    Thank you for the tip zbor.
    You are totally correct.

    Meanwhile I was seeing the formula you used, and seems that the result of your formula will only sum when S2, T2 etc >0, and not =0.
    I was trying your formula and seems that it only counts when a row has all the columns with values greater than zero, when it should be the opposite, right?

    I did change the formula to:

    Please Login or Register  to view this content.
    The problem is that it counts the blank cells as you said. So in my case it counts me 999 times because I had no data at that range.
    Last edited by FCarv; 09-11-2012 at 10:36 AM.

  9. #9
    Forum Contributor
    Join Date
    09-11-2009
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    102

    Re: COUNTIF Formula help

    hi,
    you can use formula below:
    =SUMPRODUCT((CONCATENATE(S2:S10000,T2:T10000,U2:U10000,V2:V10000,W2:W10000)="00000")*(1))
    ^0^

  10. #10
    Forum Contributor
    Join Date
    09-11-2009
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    102

    Re: COUNTIF Formula help

    hi,
    you can use formula below:
    =SUMPRODUCT((CONCATENATE(S2:S10000,T2:T10000,U2:U10000,V2:V10000,W2:W10000)="00000")*(1))
    ^0^

  11. #11
    Registered User
    Join Date
    06-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: COUNTIF Formula help

    You are correct FCarv, the formula needs to count a row if the values of the colums in that row all equal zero

  12. #12
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: COUNTIF Formula help

    =if(and(s2=0,t2=0,u2=0,v2=0,w2=0),countif(s2:w1000,0),"")

  13. #13
    Registered User
    Join Date
    08-17-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    82

    Re: COUNTIF Formula help

    Ok, to sum up:

    Fotis, your formula will result in counting every zero in that area.
    Supposenly you can only count "1" when all the columns are zero, i.e., when Sx=0, Tx=0, Ux=0 and Vx=0, all together.

    The formula from duanz does exactly what MROMAR wants but it gives an error (#NUM!) when there is nothing to count. Example: When all the cells from S2:W1000 are different from zero.

    The formula zbor suggested with the modification I have made has that flaw that counts the blank cells. But still if you don't have blank cells you will be ok.

  14. #14
    Registered User
    Join Date
    08-17-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    82

    Re: COUNTIF Formula help

    Ok, if you use this one you WILL get the result you want. A small modification to duanz formula:

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    06-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: COUNTIF Formula help

    Quote Originally Posted by FCarv View Post
    Ok, if you use this one you WILL get the result you want. A small modification to duanz formula:

    Please Login or Register  to view this content.
    It says there is an error

  16. #16
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: COUNTIF Formula help

    @ FCarv

    Fotis, your formula will result in counting every zero in that area.
    Supposenly you can only count "1" when all the columns are zero, i.e., when Sx=0, Tx=0, Ux=0 and Vx=0, all together.
    Are you sure?

    In post#3,MROMAR said:

    T
    hat doesn't work because that just counts the total number of zeros in the columns.

    I need it only to recognize when S2=0 T2=0 U2=0 V2=0 and W2=0

    If any of those value are greater than zero then do not count it, so if S2=5 T2=0 U2=0 V2=0 and W2=0, then that row should not be counted
    My(second) formula does this.

  17. #17
    Forum Contributor
    Join Date
    09-11-2009
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    102

    Re: COUNTIF Formula help

    Quote Originally Posted by MROMAR View Post
    It says there is an error
    attached file to explain. no error.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    06-13-2012
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: COUNTIF Formula help

    Works perfect, thank you so much

    Everyone's help is highly appreciated.

  19. #19
    Registered User
    Join Date
    08-17-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    82

    Re: COUNTIF Formula help

    Quote Originally Posted by MROMAR View Post
    It says there is an error
    Sorry MROMAR, I forgot you were from Canada, you had to change the ";" between parameters to ",". In Europe we do things slightly different I guess

    Quote Originally Posted by Fotis1991 View Post
    @ FCarv
    Are you sure?
    Yes, because it would count every single zero within the range you selected, i.e., S2:W1000.
    For the example MROMAR gave it would provide you with the result of 4, because S2=5 and the four remaining columns were zero. And the ressult should be 0 because only when all columns are zero it should provide you with a result of 1

    I dunno if I'm being clear but I'm making an effort

  20. #20
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: COUNTIF Formula help

    Why not COUNTIFS?, try

    =COUNTIFS(S:S,0,T:T,0,U:U,0,V:V,0,W:W,0)
    Audere est facere

  21. #21
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: COUNTIF Formula help

    This will count the rows with 5 zeros and ignore blank rows
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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