Counting for 3 consecutive non zero numbers

sonyaltec

New Member
Joined
Feb 10, 2023
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Need help for a formula to count how many consecutive non-zero months in a year but count resets after each 3 consecutive months is achieved.
eg1: if all months value >1, count as 4 consecutive 3-months block.
eg2: 1,1,0,1,1,1,1,0,0,1,1,1 = count as 2 consecutive 3-months block.
eg3: 1,1,1,1,1,0,1,1,1,1,1,1 = count as 3 consecutive 3-months block.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Is the "1,1,0,1,1,1,1,0,0,1,1,1" text string within a single cell (for ex: A1), or, spread into 12 single cells (for ex: A1:L1)?
 
Upvote 0
Book1
ABCDEFGHIJKLMN
11101111001112
21111101111113
Sheet7
Cell Formulas
RangeFormula
N1:N2N1=SUM(FLOOR(FREQUENCY(IF(A1:L1,COLUMN(A1:L1)),IF(A1:L1,0,COLUMN(A1:L1)))/3,1))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 1
Solution
Try this

Book1
ABCDEFGHIJKLM
1123456789101112
21111011101112
31111111111114
Sheet1
Cell Formulas
RangeFormula
M2:M3M2=SUMPRODUCT(--(COUNTIF(OFFSET($A2,0,{0,3,6,9},1,3),1)=3))


.
 
Upvote 0
Try this

Book1
ABCDEFGHIJKLM
1123456789101112
21111011101112
31111111111114
Sheet1
Cell Formulas
RangeFormula
M2:M3M2=SUMPRODUCT(--(COUNTIF(OFFSET($A2,0,{0,3,6,9},1,3),1)=3))


.
I think M2 should count 3 since A2:D2 contains a 3-month block.
 
Upvote 0
Try this

Book1
ABCDEFGHIJKLM
1123456789101112
21111011101112
31111111111114
Sheet1
Cell Formulas
RangeFormula
M2:M3M2=SUMPRODUCT(--(COUNTIF(OFFSET($A2,0,{0,3,6,9},1,3),1)=3))


.
Change A2 into a zero and you'll see this does not work unfortunately
 
Upvote 0
Book1
ABCDEFGHIJKLMN
11101111001112
21111101111113
Sheet7
Cell Formulas
RangeFormula
N1:N2N1=SUM(FLOOR(FREQUENCY(IF(A1:L1,COLUMN(A1:L1)),IF(A1:L1,0,COLUMN(A1:L1)))/3,1))
Press CTRL+SHIFT+ENTER to enter array formulas.
Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,080
Members
449,205
Latest member
Healthydogs

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