Most Consecutive appearances in a range

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
777
Office Version
  1. 365
Platform
  1. MacOS
Hi,

I have the below worksheet (see first image), which lists all of my completed parkruns.

Most Consecutive parkrun Events (Venues) - 1.jpg


What I want to identify from this range (C4:C2003) is which event that I have done the most times consecutively (rather than the most times in total). I have manually calculated the correct figures (highlighted in yellow) for illustration of what I’m trying to achieve. As well as identifying which event it is, I’d also like to show the earliest and latest date for which this consecutive range took place.

On top of those three calculations, I’d also like to populate the second worksheet (see second image, below) with the actual list of the consecutive events, along with their number in the run and the dates. I’m guessing some sort of FILTER function might be needed for this. I've again highlighted in yellow, the manual results I am trying to automate.

Most Consecutive parkrun Events (Venues) - 2.jpg


I'd like to avoid adding any helper columns to these worksheets, if at all possible.

I have added a link to the (small) file, here: https://1drv.ms/x/c/f08b781118912fd2/Ee0-4PthSBBOtjXBxvogX0MBjJ76ECnenE_AJLdZyK_Wmg?e=51q17t

Thanks in advance!

Olly.
 
Give this a try:
Book1
ABCDEFGHIJKL
1MY parkruns - ALL COMPLETED RUNS
2All of my parkruns, including all information / data / calculations. The majority of the other worksheets, in this section, use this worksheet to calculate.
3Run #Event (Venue) Run #Event (Venue)CountryDate CompletedFinishing Position #Consecutive Matching Events (Venues)Event# ConsecutiveEarliest DateLatest Date
413Newport parkrunUnited Kingdom9/4/11541Newport parkrun819/4/1121/05/2016
Sheet3
Cell Formulas
RangeFormula
I4:J4I4=LET(s,SCAN(0,C4:C407=C5:C408,LAMBDA(a,b,IF(b,a+1,0))),m,MAX(s),h,HSTACK(XLOOKUP(m,s,C4:C407),m+1),h)
K4K4=LET(s,SCAN(0,C4:C407=C5:C408,LAMBDA(a,b,IF(b,a+1,0))),m,MAX(s),XLOOKUP(1,TAKE(s,XMATCH(m,s)),TAKE(E4:E410,XMATCH(m,s))))
L4L4=LET(s,SCAN(0,C4:C407=C5:C408,LAMBDA(a,b,IF(b,a+1,0))),m,MAX(s),XLOOKUP(m,s,E4:E407))
Dynamic array formulas.
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(0,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,HSTACK(INDEX(f,r-MAX(s)+1,{1,3}),INDEX(f,r,3)))
Also, is there a way to display each result individually, rather than all as a result of one formula? As I may need to display just one or two of each in particular areas.
 
Upvote 0
Give this a try:
Book1
ABCDEFGHIJKL
1MY parkruns - ALL COMPLETED RUNS
2All of my parkruns, including all information / data / calculations. The majority of the other worksheets, in this section, use this worksheet to calculate.
3Run #Event (Venue) Run #Event (Venue)CountryDate CompletedFinishing Position #Consecutive Matching Events (Venues)Event# ConsecutiveEarliest DateLatest Date
413Newport parkrunUnited Kingdom9/4/11541Newport parkrun819/4/1121/05/2016
Sheet3
Cell Formulas
RangeFormula
I4:J4I4=LET(s,SCAN(0,C4:C407=C5:C408,LAMBDA(a,b,IF(b,a+1,0))),m,MAX(s),h,HSTACK(XLOOKUP(m,s,C4:C407),m+1),h)
K4K4=LET(s,SCAN(0,C4:C407=C5:C408,LAMBDA(a,b,IF(b,a+1,0))),m,MAX(s),XLOOKUP(1,TAKE(s,XMATCH(m,s)),TAKE(E4:E410,XMATCH(m,s))))
L4L4=LET(s,SCAN(0,C4:C407=C5:C408,LAMBDA(a,b,IF(b,a+1,0))),m,MAX(s),XLOOKUP(m,s,E4:E407))
Dynamic array formulas.
Thanks. Similar to fluff's solution, this almost works, except for the max date, the max date is one too low. The streak should end on 28/05/2011.
Screenshot 2024-11-10 at 18.30.22.jpg
 
Upvote 0
How about
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,HSTACK(INDEX(f,r-MAX(s)+1,{1,3}),INDEX(f,r,3)))
 
Upvote 0
How about
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,HSTACK(INDEX(f,r-MAX(s)+1,{1,3}),INDEX(f,r,3)))
Yes, that works, thanks. Is there any way that I can use the formula to display each part of the data separately?
 
Upvote 0
Like
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,r-MAX(s)+1,1))
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,r-MAX(s)+1,3))
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,r,3))
 
Upvote 0
Like
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,r-MAX(s)+1,1))
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,r-MAX(s)+1,3))
Excel Formula:
=LET(f,FILTER(C4:E2003,C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,r,3))
Thanks, that's great. Any idea on a spill formula for the second worksheet, at all?
 
Upvote 0
How about
Excel Formula:
=LET(f,FILTER('All Completed Runs'!C4:E2003,'All Completed Runs'!C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,INDEX(f,SEQUENCE(MAX(s),,r-MAX(s)+1),{1,3}))
 
Upvote 0
Brilliant, that works perfectly - thank you. Is there a way to add in the values for column a, i.e. 1-81? Just number each entry, unless the value of B is "".
 
Upvote 0
How about
Excel Formula:
=LET(f,FILTER('All Completed Runs'!C4:E2003,'All Completed Runs'!C4:C2003<>""),v,TAKE(f,,1),s,SCAN(1,DROP(v,-1)=DROP(v,1),LAMBDA(a,b,IF(b,a+1,1))),r,XMATCH(MAX(s),s)+1,HSTACK(SEQUENCE(MAX(s)),INDEX(f,SEQUENCE(MAX(s),,r-MAX(s)+1),{1,3})))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,629
Messages
6,173,434
Members
452,514
Latest member
cjkelly15

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