Longest Streak Formula in Excel and Google Sheets (Consecutive Days)

SubtbStudio · Updated 26 November 2026 · 2 min read

In a habit tracker, a streak is the number of consecutive days a habit was done. Spreadsheets have no STREAK function, but two formulas get you there. The examples use a row of 14 days in B5:O5, where 1 means done and 0 (or blank) means not done:

1  1  0  1  1  1  0  0  1  1  1  1  0  1

The longest streak here is 4 (days 9 to 12), and the current streak, counting back from the last day, is 1.

Longest streak

=MAX(FREQUENCY(IF(B5:O5=1, COLUMN(B5:O5)), IF(B5:O5<>1, COLUMN(B5:O5))))

In Excel 365 and Google Sheets it works as a normal formula. In Excel 2019 and older, confirm it with Ctrl+Shift+Enter (an array formula); in Google Sheets you can also wrap it in ARRAYFORMULA().

How it works

  1. IF(B5:O5=1, COLUMN(B5:O5)) lists the column numbers of the done days.
  2. IF(B5:O5<>1, COLUMN(B5:O5)) lists the column numbers of the missed days. These act as "walls".
  3. FREQUENCY(data, bins) counts how many done days fall between each pair of walls, which is exactly the length of each run.
  4. MAX picks the longest run.

Current streak (ending on the last day)

=IFERROR(COLUMNS(B5:O5) - MAX(IF(B5:O5<>1, COLUMN(B5:O5) - COLUMN(B5) + 1)), 0)

This finds the position of the last missed day and counts how many days come after it. If there are no missed days at all, MAX of an empty list returns 0 and the whole row counts. It is also an array formula in older Excel.

In a monthly tracker you usually want the streak up to today, not to the end of the month. Limit the range to today's column, or treat future days as "not yet" rather than missed.

Using ticks instead of 1s

If you tick days with ✓ or x, replace B5:O5=1 with (B5:O5="✓")+(B5:O5="x")>0 and B5:O5<>1 with (B5:O5="✓")+(B5:O5="x")=0.

A version without array formulas

If you'd rather avoid array formulas (they can be slow on big sheets and confusing to edit), add a helper row underneath that counts the running streak:

B6:  =IF(B5=1, 1, 0)
C6:  =IF(C5=1, B6 + 1, 0)    (copy to the right)
Longest streak:  =MAX(B6:O6)
Current streak:  =O6

Hide the helper row if you like. It is easy to understand, fast, and works in every spreadsheet app.

Tested in LibreOffice Calc with the example row above (longest = 4, current = 1). Excel and Google Sheets use the same function definitions.

This guide was drafted with AI assistance; the formulas and worked examples were checked in a spreadsheet before publishing.