Number of consecutive days - streak

#1

I have a table where I keep entries for workouts for a group of friends. One thing I implemented in gdoc (and which is a massive motivator), is a personal streak.
This is: the number of consecutive days the person has worked out. You skip a day? => your streak starts over again.

Is there a way to do this in a coda table?

#2

Dear @Stijn_Muylle,

Just some brainstrorming:
With the method decribed in the post, it should be possible, the only change should be that the days will be monitored, instead of the month.
And then you could compare the start day to end day with the actual workout period and in case there is a difference the streak has to start again.

On your way creating, for sure you will face some challanges, but the community will be glad to support you.

Success, :handshake:
//JP

#3

You should be able to achieve this using a recursive formula: thisTable.Filter(Date = thisRow.Date - 1).[Cumulative Days].First().IfBlank(-1) + 1

Breaking it down:

  1. Find the row(s) for the previous day:
    thisTable.Filter(Date = thisRow.Date - 1)
  2. Get the prior cumulative day count:
    thisTable.Filter(Date = thisRow.Date - 1).[Cumulative Days].First()
  3. If no prior date exists then start with -1, then add 1 to value. So if no day was found -1 + 1 = 0:
    thisTable.Filter(Date = thisRow.Date - 1).[Cumulative Days].First().IfBlank(-1) + 1

Nigel.

1 Like
#4

Hi Nigel,

Thanks explaining this technique :beers:

Amicable,
//JP