+ Reply to Thread
Results 1 to 19 of 19

Counting sequential zeroes in column

  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Angry Counting sequential zeroes in column

    Hi All,

    Having a bit of a of a "hair tearing out" problem.

    How do i go about having a formula which will return the number of times 0 is repeated in a column sequentially?

    e.g.:

    0
    1
    0
    0
    0
    0
    0
    1
    0
    0
    0

    The idea being that after row 7 (there have been 5 consecutive zeroes), the count would reset when it hits a value greater than zero, and then count again once it hits a zero again.
    Output for the example above should be 3.

    Any suggestions? Thanks in advance!

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Counting sequential zeroes in column

    Hi there,

    easy task when You are able to use help column.
    Lets say Your sequence is in column A.
    Then if cell A1 = 0 put 1 in cell B1, otherwise B1 = 0.
    From B2 down fill formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And make SUM for column B.

    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

  3. #3
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting sequential zeroes in column

    NOt sure if the punctuation is incorrect or whether im entering it in wrong, but im getting an error if i enter it like that, and if i replace thes semi colon with a comma, then i just get the same values repeated.
    And a sum of that does not give me the number of consecutive zeroes in the column.
    Quote Originally Posted by Miroslav R. View Post
    Hi there,

    easy task when You are able to use help column.
    Lets say Your sequence is in column A.
    Then if cell A1 = 0 put 1 in cell B1, otherwise B1 = 0.
    From B2 down fill formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And make SUM for column B.


  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Counting sequential zeroes in column

    Hi,

    Assuming your entries are numerical and only ever zero or one, as in your example, use this array formula**:

    =SUM(0+(FREQUENCY(IF(1-A1:A11,ROW(A1:A11)),IF(A1:A11,ROW(A1:A11)))>0))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Click * below if this answer helped

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

  5. #5
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Counting sequential zeroes in column

    oh... sorry for that...
    You work with 2010, so yes = replace ';' with ','.

    See attachement

    Book2.xlsx
    Last edited by Fotis1991; 05-21-2014 at 08:43 AM.

  6. #6
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting sequential zeroes in column

    Hi XOR LX,

    Thanks all for the fast replies. I haven't got that to work either im afraid.
    My data starts at A2, and continues to the bottom of the sheet. Even when i enter the code you had though, again, it only seem to sum the numbers i had in that column. Not what i need either.


    Quote Originally Posted by XOR LX View Post
    Hi,

    Assuming your entries are numerical and only ever zero or one, as in your example, use this array formula**:

    =SUM(0+(FREQUENCY(IF(1-A1:A11,ROW(A1:A11)),IF(A1:A11,ROW(A1:A11)))>0))

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  7. #7
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting sequential zeroes in column

    Ah i see now what that formula does Miroslav. Sorry, crossed wires here id imagine. What your formula does is give me the number of times there were sequential 0's together.

    What im looking for is how many zeroes are there in sequence as per the last entries in the workbook.
    The function im using is for counting batches where no fail results were observed, so once it reaches 5, the test level can drop. So i need to know, as per the last entries, how many batches have had 0 failures.

    Hope that clarifies things!

    Quote Originally Posted by Miroslav R. View Post
    oh... sorry for that...
    You work with 2010, so yes = replace ';' with ','.

    See attachement

    Attachment 319760

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Counting sequential zeroes in column

    Quote Originally Posted by darrenfiend View Post
    Hi XOR LX,

    Thanks all for the fast replies. I haven't got that to work either im afraid.
    My data starts at A2, and continues to the bottom of the sheet. Even when i enter the code you had though, again, it only seem to sum the numbers i had in that column. Not what i need either.
    And, since you haven't said otherwise, I assume I was correct that your data consists entirely of zeroes and ones, in number format (not text)?

    And you adjusted the ranges to suit your actual set-up?

    And you followed the instructions correctly re array formulas?

    Regards

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Counting sequential zeroes in column

    Quote Originally Posted by darrenfiend View Post
    My data starts at A2, and continues to the bottom of the sheet.
    That's over a million rows' worth of data!?!!

  10. #10
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting sequential zeroes in column

    Sorry, within reason obviously. lets say A400 for arguments sake.

    as i said to Miroslav:

    "What im looking for is how many zeroes are there in sequence as per the last entries in the workbook.
    The function im using is for counting batches where no fail results were observed, so once it reaches 5, the test level can drop. So i need to know, as per the last entries, how many batches have had 0 failures."

    Quote Originally Posted by XOR LX View Post
    That's over a million rows' worth of data!?!!

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Counting sequential zeroes in column

    Have you had chance to address my previous post?

    Regards

  12. #12
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Counting sequential zeroes in column

    You may try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of just Enter.

    Please Login or Register  to view this content.
    The formula was suggested by XOR LX. I just made some changes in it to suit your requirement.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  13. #13
    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: Counting sequential zeroes in column

    Quote Originally Posted by Miroslav R. View Post
    oh... sorry for that...
    You work with 2010, so yes = replace ';' with ','.

    See attachement

    Attachment 319760
    In most of the Countries, Local settings use comma to separate in formulas.

    In few(inclunding Greece ) we use semi colon as separator in our formulas.

    This happens to ALL Excel versions. Not only in Excel 2010.
    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.

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Counting sequential zeroes in column

    Quote Originally Posted by sktneer View Post
    You may try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of just Enter.

    Please Login or Register  to view this content.
    The formula was suggested by XOR LX. I just made some changes in it to suit your requirement.
    Thanks, but an array formula referencing entire columns will take a while to calculate!!

    Cheers

  15. #15
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting sequential zeroes in column

    All the feedback and responses are great, but i still havent got the output im looking for.

    Heres what i have (1) number (2) is what i entered. (3) was the result. (4) is what i want to display (i manually entered it)
    1.PNG2.PNG3.PNG4.PNG

    Quote Originally Posted by sktneer View Post
    You may try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of just Enter.

    Please Login or Register  to view this content.
    The formula was suggested by XOR LX. I just made some changes in it to suit your requirement.

  16. #16
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Counting sequential zeroes in column

    Quote Originally Posted by XOR LX View Post
    Thanks, but an array formula referencing entire columns will take a while to calculate!!

    Cheers
    Yes I agree. OP should change the range reference as per his requirement.

  17. #17
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Counting sequential zeroes in column

    Book2.xlsx

    Not exactly, but the count You want is there... =D

  18. #18
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Counting sequential zeroes in column

    Find the attachment to see if this is what you want.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    11-15-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting sequential zeroes in column

    Excellent! Thanks sktneer! Just what i was looking for!

    Appreciate it! I owe you one!

    Quote Originally Posted by sktneer View Post
    Find the attachment to see if this is what you want.

+ 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. Adding Sequential Numbers in Column B Based on Column A Values
    By habsfan1433 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-14-2014, 04:17 PM
  2. Replies: 3
    Last Post: 01-30-2014, 05:31 AM
  3. Counting sequential cells of similar text to measure bout lengths
    By fjgolder in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-05-2013, 03:39 PM
  4. Add zeroes within dates (NOT leading zeroes)
    By anthony19 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 04:08 PM
  5. Counting number of sequential dates
    By rooshio in forum Excel General
    Replies: 5
    Last Post: 11-05-2009, 09:11 PM

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