+ Reply to Thread
Results 1 to 3 of 3

Running count

  1. #1
    Registered User
    Join Date
    11-18-2011
    Location
    london, ontario
    MS-Off Ver
    Excel 2003
    Posts
    1

    Running count

    I have a column where i have a number of 0's that appear and 1's

    looks like this

    0
    0
    0
    1
    0
    1
    0
    1
    1
    0
    0

    I need to count how many 0's occur before each 1.

    Anyone know a formula?!?

    Basically each 0 represents a unit of time, each 1 reprsents a lifetime..

    by the end of this formula the lifetime should reset back to one and not 1,2,3,4,5,6
    Last edited by needassistance; 11-18-2011 at 11:25 PM.

  2. #2
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Running count

    In B1, have =IF(A1=0,"",1). In B2 and copied down as needed, put =IF(A2=0,"",COUNTIF($A$1:A1,0)-SUM($B$1:B1)). Note that your data will have to end with a 1 for all 0s to be counted. If you want the last to be counted regardless, you could modify B2 to be =IF(A2=0,IF(COUNT(A:A)>ROWS(A$1:A2),"",1+COUNTIF($A$1:A1,0)-SUM($B$1:B1)),COUNTIF($A$1:A1,0)-SUM($B$1:B1))
    Life is about perseverance. Remember: today's mighty oak tree is just yesterday's nut that held its ground.

    If you like a post, please rate it with the scales icon (top right).
    If you feel really indebted, please consider a donation to charity, such as Feed the Children or Habitat for Humanity.

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

    Re: Running count

    Here is without helper column:
    Attached Files Attached Files

+ 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