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

Hi guys,

I have just converted from Notion a few days ago and I must say I am very excited be a part of this community. Although the formula side of things is a little daunting I am very excited to see if I can build ‘the fitness app of my dreams’ which I was forcefully trying to do within Notion but the UX simply isn’t as good as what Coda allows for via all of it’s insane functionalities. I am surprised I have never heard about Coda until a few days ago after stumbling upon a Coda template.

Anyways, I am currently working my Workspace and I must say I am very impressed (and overwhelmed) with the possibilities. So far so good but I have a bit of a formula issue I can’t get around without you guys!

Here it is:
I am trying to build a the functionality within my Tasks table that allows me add up all of the time I have spend on a specific task using the Pomodoro button I have created (I copied a timer template from within Coda’s templates). However the issue is that I have no idea how to build the formula I need to make this a reality.

Essentially what I am trying to do is:

  1. Click the “Start Pomodoro button”
  2. Timer column begins to count down
  3. End column called ‘Total Time Spent’ adds up the time I spend in the ‘focus time’. (There is focus and break time - under the ‘State’ column)
  4. When I click the ‘Take a Break’ or ‘Reset’ buttons, the ‘Total Time Spent’ stops adding up the ‘focus time’

Please see my example here: Tasks Pomodoro Test.

The reason I want to see the ‘Total Time Spent’ on a task is because I want to be able to track the time I spend on each task as I do them and then be able to see all of this data in graphs/pie charts. But that’s a problem for another day :joy:

Thanks for reading, thanks for the amazing community and can’t wait to interact with as many of you as I can!

Cheers from NZ,


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

For exemple i create task/project timer
look and inspire you I hope he can help you

1 Like

My goodness! You are an absolute champ Pch!!! (no pun intended :joy:)

I must say you the amount of effort you have put into explaining everything for me is just overwhelming ly nice of you, I can’t thank you enough. Let me buy you a virtual coffee or something! You’re the friggin man!!!

I’ll have a go at putting this together in my master doc and will update you when done here with the final results.

Thanks so much Pch!!!

1 Like

I have updated my Master sheet and it is all set up as you have designed it!

Thank you so much again Pch :1st_place_medal:

A two more questions for you Pch, I’m trying to figure out right now are:

  1. Can you code a sound file so that it activates at the end of each focus/break timer?
  2. Is there a way that the ‘Focus Sessions Logs’ can automatically log the ‘Area/Resource’ and ‘Projects’ relations that are within each Task’s rows? - I need it to do this so I can begin to generate graphs and analytics (no idea how I’m going to do this lol).

Thanks again for your help!!!

Hi @Youssef_Iskander :blush: !

I’m just passing by to let you know that I’ll get back at you ASAP with a more appropriate reply than this :innocent: .

I was quite away this weekend and didn’t have much access to my Mac :no_mouth:

Sorry for any inconvenience :no_mouth: .

No worries Pch! Talk soon and thanks again! :pray: :wave:

1 Like

Hi @Youssef_Iskander :blush:

Thanks for the compliments :smiling_face: and I’m glad to know this helped you a little :smiling_face: !

Sorry for the late reply though but to answer your questions :

I think our Coda High Wizard @Paul_Danyliuk :man_mage: did something like this when he built a pomodoro tracker during a livestream but I don’t know if the livestream is publicly shared or not as it was posted on his Patreon some time ago :blush:

So my answer here would be that it’s not natively implemented by Coda (and it would be a nice little add-on :blush: ) but, using Paul’s Trick (which might involve some Black Magic … I don’t remember :sweat_smile: ) there might be a way (but I honestly didn’t look at this, sorry :innocent: )

Yes, using Relation/Linked relation and related columns fields :blush:

I’ve had some fun re-creating the doc you shared in your initial post and mixing it with the sample doc @Math_24 shared earlier for 2 reasons :

  1. Well, as the purpose of the pomodoro technique is to focus on one task at a time, storing the “Timer” in its own one row helper table makes sense :blush:

  2. In terms of performances, I think using a one row helper table to store the task to track and the timer, then deleting it when done might help a little
    (As the timer relying on the use of Now() is limited to one row it should also limit the recalculations while the timer is running… and when done and the row can be deleted, the timer shouldn’t calculate anything as there would be nothing to do so … vs. having a timer for multiple tasks still checking if they should use Now() or not)

I’ve added descriptions to most of the fields in the sample, commented some formulas (mostly the Action formulas I think :sweat_smile: ) and left an “About” page with some info :innocent: .
Now() is also stored in its own table and page and you should find it in the “Data” section :blush:

This is just an idea :blush: … but I hope this helps :innocent:

Hi Pch,

I wanted to thank you for your concise and helpful explanations! Your work is so impressive and well-detailed :raised_hands:

Regarding the sound file implementation, I will have to message @Paul_Danyliuk to see if he can help me with that :thinking:

I’m still new to Coda, so I tried using related column fields but it didn’t work.

You were right about the Timer helper table, it really helps to focus on one task at a time. I also understand how you created the Now() table, and it makes total sense now - the checkbox is what starts and stops it, which is activated by the buttons.

Your work is too good not to use, so I will have to take your ideas and apply them to my Second Brain master tasks table :blush:

I also have a big project that I will be working on in the foreseeable future, which is a Coda fitness app unlike any other. The purpose of this app is to allow any beginner to start their fitness journey using planned training and nutrition programs, learning, and systems. I began designing a similar app in Notion last year (I can send you a link if you’d like to see it), but Coda is much more user-friendly and dynamic :muscle:

If you’re interested, I would love to hear your ongoing input as I build it. I’m sure I’ll get stuck a lot, so any feedback and advice on how to build it the way I need would be greatly appreciated! :pray:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.