STREAK

STREAK(range,lookup_value,by_row)
range
range reference to examine for streak of a given value
lookup_value
the value to identify for the streak of values
by_row
True if you want to go by rows, False to go by columns

STREAK will look at a range, and given a value, will return how many consecutive times the value appears in the range.

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,957
Office Version
  1. 365
Platform
  1. Windows
STREAK will look at a range, and given a value, will return how many consecutive times the value appears in the range.

The function can look at a single row, single column, or range with multiple rows and columns.

Excel Formula:
=LAMBDA(range,lookup_value,by_row,
    LET(t,range,
    rc,IF(by_row,COLUMN(t),ROW(t)),
        IF(by_row,
            BYROW(t,LAMBDA(x,MAX(FREQUENCY(IF(x=lookup_value,rc),IF(x<>lookup_value,rc))))),
            BYCOL(t,LAMBDA(x,MAX(FREQUENCY(IF(x=lookup_value,rc),IF(x<>lookup_value,rc)))))
        )
    )
)

LAMBDA
ABCDEFGHIJKLMNOPQRST
1BABACCCACCAABCCABAB2
2ACABAAAAABBAACACCAA5
3ACBABABABAABBBAABCA2
4BBCCAAAABBACBABCACC4
5CCAABCCACBAACBCBCBB2
6AAAAACCBBAABCCCCAAB5
7BABBCABBACABBACACAC1
8ABACCCCCAAACBCABAAA3
9ABACBBBBCBCCABCAABC2
10BBCCABAACCBCACBCCBA2
11ABBCBBCBCABBCCCBCAA2
12AAACBCCABABAAAAAABA6
132222131522622121233
14
15Single Row
165
17
18Single Column
196
Sheet2
Cell Formulas
RangeFormula
T1:T12T1=STREAK(A1:S12,"A",1)
A13:S13A13=STREAK(A1:S12,"A",0)
A16A16=STREAK(A6:S6,"A",1)
A19A19=STREAK(K1:K12,"A",0)
Dynamic array formulas.
 
Upvote 0
@Xlambda posted a cool alternative to this function. Looking at that formula gave me some insight on how I originally wanted to do this STREAK formula. Now I see how. Cheers Xlambda!

Excel Formula:
=LAMBDA(range,lookup_value,[by_row],
    LET(
        rc,IF(by_row,ROW(range),COLUMN(range)),
        m,LAMBDA(x,MAX(FREQUENCY(IF(x=lookup_value,rc),IF(x<>lookup_value,rc)))),
            IF(by_row,
                BYCOL(range,LAMBDA(b,m(b))),
                BYROW(range,LAMBDA(b,m(b)))
            )
    )
)
 

Forum statistics

Threads
1,223,604
Messages
6,173,320
Members
452,510
Latest member
RCan29

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