Reputation: 1
Question: if I have a column of data showing 010110111001111000
1=breach and 0=non-breach
Find the total number of consecutive breaches, for example '11' implies 1 consecutive breaches and '111'implies 2 consecutive breaches
By inspection, total number of consecutive breaches = 6
Is there a formula in Excel that can solve this problem?
Thank you
Upvotes: 0
Views: 536
Reputation: 2725
Here is another way:
Combining the formula:
=LEN(SUBSTITUTE(REPLACE(SUBSTITUTE(A7,"01","00"),1,1,0),0,""))
Upvotes: 1
Reputation: 152575
Use COUNTIFS with offset ranges:
=COUNTIFS(A1:A17,1,A2:A18,1)
Note the two ranges are offset one row from each other, so it counts where there are two 1
s together.
Upvotes: 2