Share
Explore

Streaks Pack User Guide

Sometimes it takes a little extra motivation to keep up with your routines and meet your goals. Knowing you are on a streak, and avoiding breaking it, can be just the push you need!
Calculating streaks can be quite complicated in Coda, requiring some fancy formulas. Lucky for you there is a Pack that makes it simple:
Demo
Below is a very simple table, which logs whether you’ve worked out on a given day. The Streak column uses the Pack to calculate how long the streak was on each day.
Try it! Add rows and toggle checkboxes to see it recalculate the streaks.
Workouts
1
Date
Complete
Streak
Date
Complete
Streak
1
1/1/2023
1
2
1/2/2023
2
3
1/3/2023
3
4
1/4/2023
0
5
1/5/2023
1
6
1/6/2023
2
7
1/9/2023
1
8
1/10/2023
2
9
1/11/2023
3
There are no rows in this table
You’re on a
3
day streak.
Keep it up!
Setup
Select the columns to used to calculate the streak.
The first must be a Date column, representing the date of the entry.
The second must be a Checkbox column, indicating if the goal was met on that date. You can use a formula to calculate the value of this checkbox column, if it is dependent of various data points in the row.
Add a new Number column to hold the streak value.
Add a formula to that column, with the following format: Streaks(Table.Date, Table.Checkbox).Nth(Table.Find(thisRow)) Replace Table with the name of the table, Date with the name of the Date column, and Checkbox with the name of the checkbox column. For example, here’s the formula used in the demo table above:
Streaks(Workouts.Date, Workouts.Complete).Nth(Workouts.Find(thisRow))

That’s it! You should now have a streak value for each row in your table.
How it works
Unlike most formulas which work on a single row at a time, calculating a streak requires looking at all of the previous rows. To improve performance, the formula calculates all of the streak values for the entire table in one go.
For example, here is the result of calling the Streaks() formula on the demo table above.
Streaks(Workouts.Date, Workouts.Complete) =>
123012123
Notice how you pass in the entire column of dates and the entire column of checkboxes, and then get back an entire column of streaks.
Once you have the total set of streaks, it’s just a matter of displaying the right value for each row. Table.Find(thisRow) gets the row number of the current row, and then .Nth() pulls out the corresponding streak at that index.
Advanced options
What happens if you get sick and miss a few days? Should that break the streak? Well, the answer may depend on how strict you want to be with yourself, but you can use the Streaks() formula either way!
To allow for gaps in the log without breaking the streak, set the advanced option allowGaps.
Streaks(Workouts.Date, Workouts.Complete, allowGaps: true) =>
123012345
Notice how the streak continues even though days are missing.
Search
Date
Complete
Streak
Streak (allow gaps)
Date
Complete
Streak
Streak (allow gaps)
1
1/1/2023
1
1
2
1/2/2023
2
2
3
1/3/2023
3
3
4
1/4/2023
0
0
5
1/5/2023
1
1
6
1/6/2023
2
2
7
1/9/2023
1
3
8
1/10/2023
2
4
9
1/11/2023
3
5
There are no rows in this table

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.