Why did my formula break?

Hey there Coda Community,

I have built a time tracking function in one of our docs. There are currently two people using this doc daily to track working hours, etc.

I have separated all elements that are used in the time tracking into a demonstration doc: Why isn't the time tracking working

We have been using this doc for a couple of months without any issues. I believe it was last Thursday (the 8th of December) that we started getting very strange behavior.

Symptoms:
It keeps reporting “you forgot to log out” even if you’re only logged in for a couple of seconds. This should only happen, when you are logged in for longer than 8 hours.

in the newly created doc for presenting the issue to you the bug can currently not be reproduced.

Does anyone have a clue what happened here? Or a more elegant way of tracking time?
Also I would really appreciate a way to structure bigger formulas like this better in the editor. Maybe even a debugging tool?

Hey Kevin, thanks for reaching out! It looks like all of your formulas are set up in a way where nothing will calculate if the WorkStartTMP column is blank (the second filter argument). I think that’s why they all appear broken. Also, instead of stringing Filter() formulas together, use one Filter() formula and separate the arguments using AND/OR logic. Here’s a GIF of what that looks like: GIF link.

If you want to test your formula’s efficiency, we have a calculation analyzer tool you can use as well: Troubleshooting calculation performance issues | Coda Help Center. If you’re building a timer, the best thing you can do to save your doc’s performance is to add a parameter to your Now() formula(s) so the doc isn’t constantly calculating. E.g. Now(“minute”) or Now(“hour”) so the formula updates every minute or hour instead of every second.

Hope this helps as a starting point!

Hey Renita,

Thank you very much for your response. The WorkStartTMP column gets populated when “logging in” through the “Einstempeln” button on the front page. It logs the current time so I can calculate how long the person is currently working.
It is unfortunate that this sort of code (the action of my main button) can not easily be structured more clearly. I tried by outsourcing some calculations to formulas on a page that are then used by the action of the button.

I think if you change the filter argument, you can work around that issue. It’s your second filter argument that’s causing the behavior.

Basically, your filter has the following arguments if you simplify the formula: Filter( User = User() AND WorkSmartTMP.IsNotBlank() ).

Instead, only filter by the User. E.g. Filter( User = User() ). Sorry if that wasn’t clear from my first message. Hope this helps!

Screen Shot 2023-01-03 at 12.07.16 PM

It actually started working again just fine without me changing anything. Not sure what happened there. Thank you for your help anyways :slight_smile:

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