Formula needed for Pomodoro 'Total Time Spent' on a Task

Hi @Youssef_Iskander and Welcome to the Community :partying_face: !

So, I’ve modified a “little” bit your sample doc :innocent: (Thanks for sharing :raised_hands: ) which I think should (maybe somewhat) do what you asked :blush:

But, given this requirement:

It got a little bit more complicated :sweat_smile: … As going there directly allows to do this :point_down:

… a bit more purposefully :blush:

So, what changed in your doc ? :smile: :

Well, I’ve added a text field to store the row Unique ID where the task sits simply because if you want to track the time spent on a task, the tasks you track should be absolutely unique and using their names or other properties might lead to unnecessarily complex formulas or unexpected results if you have multiple tasks with the same names :blush:.

Then, I’ve added a table called [Focus Sessions Logs] to store all the focus sessions for a specific task.

The table is populated and/or modified by your buttons [Start Timer] and [Reset Timer] if necessary.

I’ve adapted and commented the formulas in these buttons trying to leave you some info about what they do exactly, hoping it would help :innocent: .

But just in case, what the button [Start Timer] also does now is adding a row to the table [Focus Sessions Logs] with various info about the task when a session starts and when pushed a second time because you’re taking a break, it timestamps the end of the focused session started earlier :blush: .

For the [Reset Timer], when pushed, it will only timestamp the end of a focus session if there’s currently one… If not, it won’t do anything :blush:

As for the [Total Time Spent] field, if there’s a focus session currently occurring, it will display how much time has passed since the beginning of the session (which is optional or could be modified)… In any other cases, it displays the effectively total time spent on the task sitting in the row :blush: .

This should allow you to gather datas about your tasks, creates charts (and/or others), etc… in the future :innocent:

Note that depending on how you want to manipulate your tasks (create them, store them, archive them, etc…) you could also use Relation/Linked relation fields to link them where and/or when needed to what they could be linked (:sweat_smile: ).

You could also store the task statuses and the statuses of your Pomodoro timer in their own tables as it’s always easier to modify these types of things when they’re stored in their own table (as you would use a row reference in your formula, meaning that when a row is updated in the table, all the formulas using the row will be automatically updated too) than having to modify each formula where you used these to keep the formulas alive and working (as if you modify the Pomodoro status "break" for example, everywhere you used something like thisRow.State="break" you would also need to update the formula with the updated status because the text values won’t match anymore)

:warning: A little something about Now(): Be careful with its use :innocent: .

Now() lives in your browser and in this case (as it uses its default precision set to “second”) , is recalculated every seconds when used in a live formula, meaning that Now() can become a burden for a doc which might get slow …

As long as Now() is used within a button, it shouldn’t be a problem because it will only calculated when the button is pushed but elsewhere, that could be another story :sweat_smile:
At least, that how it worked the last time I checked :innocent:

A possible workaround I didn’t put in place in your doc could be to store Now() somewhere else in your doc (in a named canvas formula for example) and re-use that value where and when needed (as in that case, it’s only recalculated once, still every second but just once).

You could run some tests while using the Debug calculations tool to see what would be the best way to use Now() considering what you’re trying to accomplish with your doc :blush: (as well, sometimes, you just can’t avoid using Now() :smile: )

You’ll find the Debug calculation in the Settings of your doc, specifically in the Doc map menu where at the top, you can click on the 3 vertical dots ().
It will open a dropdown where the only option available is Debug calculations :blush: .

I’m sorry for the length :sweat_smile: … But I hope this helps you a little :innocent: !

1 Like