Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-formula

How to find the last date in the longest consecutive streak of dates in a column?


Following up on this question which was answered by Player0, how would we write a formula to find the last date in the longest consecutive streak, which would be July 12?

July 12 would be the right answer

And similarly, is there a way to find the last date of the latest streak, which would be July 23?

July 23 would be the right answer

I’ve tried various ways of using INDEX and MATCH, along with other functions, and nothing’s been working so far.


Solution

  • Here's one approach:

    =let(Σ,A5:A,
         Λ,scan(,Σ,lambda(a,c,ifs(c="",,row(c)=row(Σ),1,c-1=offset(c,-1,),a+1,1,1))),
         filter(Σ,Λ=max(Λ)))
    

    enter image description here