Hello everyone! I have a table called 'Activities' with a column 'Date' containing the dates of all the workouts. Starting from today's date, I would like to know for how many consecutive days I have been working out. If I skip a day, I would like the count to reset to zero. How can I do that? Thank you very much!
Create a virtual column with
COUNT(
FILTER(
"your table",
[Date] = ([_THISROW].[Date] - 1)
)
)
> 0
which checks if a row exists for the previous day of each row.
Then you can count the number of consecutive days up to each row by
IF(
[Check Flag],
[Date]
-
MAX(
SELECT(
your table[Date],
AND(
[Date] < [_THISROW].[Date],
NOT([Check Flag])
)
)
)
/24 + 1
,
1
)
Hopefully there will be no performance issues when your workouts progress and the number of rows gets very large..
User | Count |
---|---|
15 | |
12 | |
9 | |
8 | |
4 |