Formula to count the number of sets of 7-consecutive-zero's in a row of data

Joined
Oct 7, 2016
Messages
2
I have a database with 300 rows and 50 columns. The cells are populated with either zero, one or blank. I'm looking for a formula that I can plug into column number 51 for the 300 rows, that will tell me how many sets of 7-consecutive-zero's there are in each row.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Let me further clarify, it should count the sets of at least 7 OR MORE consecutive zero's. i.e. If there is a set of 8 zero's this set should be counted as one, not two, sets. If there is a set of 14 consecutive zero's, this should be counted as one set, not two.
I have a database with 300 rows and 50 columns. The cells are populated with either zero, one or blank. I'm looking for a formula that I can plug into column number 51 for the 300 rows, that will tell me how many sets of 7-consecutive-zero's there are in each row.
 
Upvote 0
Hi,

Based on that data being in A1:AX300, in AY1, array formula**:

=COUNT(1/(FREQUENCY(IF(A1:AX1=0,COLUMN(A1:AX1)),IF(A1:AX1<>0,COLUMN(A1:AX1)))>6))

Copy down as required.

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).
 
Upvote 0
Assuming data in A2:AX2 try this array formula
=SUM(IF(FREQUENCY(IF((A2:AX2<>"")*(A2:AX2=0),COLUMN(A2:AX2)),IF(1-(A2:AX2<>"")*(A2:AX2=0),COLUMN(A2:AX2)))>=7,1))

confirmed with Ctrl+Shift+Enter, not just Enter

copy down

@XOR LX
As there are blank cells, i *think* is necessary to include the condition (A1:AX1<>"") in your formula.

M.
 
Upvote 0
@XOR LX
As there are blank cells, i *think* is necessary to include the condition (A1:AX1<>"") in your formula.

Hi, Marcelo.

Good point. I assumed that these "blanks" were null strings (""), in which case my formula is fine. If there are actually "genuine" blanks then, yes, my formula will fail.

Regards
 
Upvote 0
@Marcelo

We could also use EXACT, so as to perform just a single check:

=COUNT(1/(FREQUENCY(IF(EXACT(A1:AX1,0),COLUMN(A1:AX1)),IF(1-EXACT(A1:AX1,0),COLUMN(A1:AX1)))>6))


Regards
 
Upvote 0

Forum statistics

Threads
1,214,881
Messages
6,122,074
Members
449,064
Latest member
MattDRT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top