Count of consecutive runs

tigerzen

Board Regular
Joined
Mar 8, 2023
Messages
165
Office Version
  1. 365
Platform
  1. Windows
I'm after a way of counting the number of consecutive non-zero "hits". The spreadsheet should show what I'm after but essentially we need to show how many times there was 1 hit, how many times there were 2 hits etc. To the right of the data are the actual numbers of consecutive hits.

Book13
ABCDEFG
1HitsMonth
23Jan-20Streaks
31Feb-201234
40Mar-201212
52Apr-20
60May-20
71Jun-20
83Jul-20
90Aug-20
101Sep-20
111Oct-20
123Nov-20
130Dec-20
144Jan-21
153Feb-21
162Mar-21
172Apr-21
180May-21
193Jun-21
202Jul-21
213Aug-21
222Sep-21
231Oct-21
240Nov-21
Sheet1
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I only count 1 streak of 4 consecutive non-zero "hits" (Jan-21 to Apr-21) not 2 as your expected result shows. If that is correct ( 1 not 2 ) then the following might be what you're looking for? This may do until a more elegant solution arrives :)

Book3
ABCDEFGH
1HitsMonth
23Jan-20Streaks
31Feb-2012345
40Mar-2012111
52Apr-20
60May-20
71Jun-20
83Jul-20
90Aug-20
101Sep-20
111Oct-20
123Nov-20
130Dec-20
144Jan-21
153Feb-21
162Mar-21
172Apr-21
180May-21
193Jun-21
202Jul-21
213Aug-21
222Sep-21
231Oct-21
240Nov-21
Sheet1
Cell Formulas
RangeFormula
D4:H4D4=SUM(--(FREQUENCY( IF($A$2:$A$24>0, ROW($A$2:$A$24)), IF($A$2:$A$24<=0, ROW( $A$2:$A$24))) =D3))
 
Upvote 0
Solution
Thanks Kevin, that works beautifully. I'd be lying if I said I understood the formula completely but I'll break it down to try and get a better understanding of it.
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,673
Members
449,179
Latest member
fcarfagna

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