countif # two consective cells have zeros

cpicsonly

New Member
Joined
Feb 9, 2016
Messages
3
I have data in excel like this
A
B
C
D
E
F
G
H
I
J
K
L
M
N
0
0
0
0
22
55
7
3
0
0
0
5
44
5

<tbody>
</tbody>




I want to countif consecutive two cells have "SAY value" 0

So first 4 columns will return frequency function =2
if all columns given as cell range for formula, then frequency should be = 3
as at end only 3 columns have two consecutive zero cell.
How can i write formula. I tried if and array but making mistake.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi.

I believe there must be a simpler solution using COUNTIFS, though I can't seem to construct it quite right.

This array formula** should work:

=SUM(QUOTIENT(FREQUENCY(IF(Range=0,COLUMN(Range)),IF(Range<>0,COLUMN(Range))),2))

Substitute Range 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
Hi.

I believe there must be a simpler solution using COUNTIFS, though I can't seem to construct it quite right.

This array formula** should work:

=SUM(QUOTIENT(FREQUENCY(IF(Range=0,COLUMN(Range)),IF(Range<>0,COLUMN(Range))),2))

Substitute Range 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).


Dear sir @XOR LX
You are absolutely right. The formula worked perfectly without any change.

Now one more query plz. (Donot give me fish but teach me to grab ONE)

I removed quotient text from formula, it gives count of number of zeros in a row, which is higher than counted by frequency function alone. I checked info of quotient function, which returns integer from a ratio. But never came across division in above formula. Can u plz describe me the logic

plz.
 
Upvote 0
@cpicsonly

If you don't want treat empty cells as 0 (what IF does), try to also run an ISNUMBER test:
Rich (BB code):
=SUM(QUOTIENT(FREQUENCY(IF(ISNUMBER(A1:N1),IF(A1:N1=0,COLUMN(A1:N1))),
    IF(ISNUMBER(A1:N1),IF(1-(A1:N1=0),COLUMN(A1:N1)))),2))
 
Upvote 0
@cpicsonly

If you don't want treat empty cells as 0 (what IF does), try to also run an ISNUMBER test:
Rich (BB code):
=SUM(QUOTIENT(FREQUENCY(IF(ISNUMBER(A1:N1),IF(A1:N1=0,COLUMN(A1:N1))),
    IF(ISNUMBER(A1:N1),IF(1-(A1:N1=0),COLUMN(A1:N1)))),2))

@Aladin
Even better !
thanks
 
Upvote 0
@Aladin
Even better !
thanks

You are welcome. The following, again confirmed with control+shift+enter, might help to understand QUOTIENT...

=INT(SUM(FREQUENCY(IF(ISNUMBER(A1:N1),IF(A1:N1=0,COLUMN(A1:N1))),IF(ISNUMBER(A1:N1),IF(1-(A1:N1=0),COLUMN(A1:N1))))/2))
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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