[Solved] How to show average duration

Hi, I am trying to show the average duration of a task.

I collect the start time and the end time of tasks. I have tried putting a duration field into the database, but as I already have the start and end time, it means I am adding things that I have to remember to hook up to my calculations.

As such, whereas

works , I would like to be able to do this in a way that I am not repeating myself (i.e. I want to get rid of the Duration ACTUAL field and calculate this from start and end times)

This works for getting the duration of a single task:

How do I get the average duration?


Is it even possible to work out? or must I have the task duration field in my database? As I said, I cannot seem to get it to delete each item’s start time from its end time…

It’s possible…
Do search for Periods:format as text:split by |:each item converted to number:average
In format as text set this periods End time - Start time
Delimiter to | (or something like that, don’t use comma)


You need to work out the duration for each task, and then calculate the average from that.

You can use the :format as text operator on the list to help you with this.


I understand that I must work out the duration of each task, but I can’t work out how to do that within this expression.

The duration of a task is simply the end time minus the start time.
The average will then be the total of all durations, divided by the number of tasks.

But Bubble won’t let me do “each item’s end time, minus, each item’s start time”

I don’t understand how formatting any part of this as text helps me?

Search for periods:format as text…
Review my reply… everything is there

1 Like

I understand the first part, it’s just everything after that I don’t understand:

How does one use Format content as text in this context?


No search again.
Use This periods end time - this period start time…

again, you don’t seem to take time to read reply completely. Everything is in my first reply.

Ok, in order for me to understand what’s going on here:

Do search for Periods - gets me the periods I want to source my data from

:format as text - I am creating a list of those periods durations?

(Was the format as minutes necessary / correct? If so, why / why not? Thanks!)

:split by | - I believe I have done this, but have no idea why or what for - if you would explain, that would be champion! Thanks

:each item converted to number - I believe I have done this?

:average - I presume you are using this phrase as a shortcut, as I cannot get it to do this?

In format as text set this periods End time - Start time
Delimiter to | (or something like that, don’t use comma)



So… YOu get a list from do a search. format as text will format each item in this list the way you want. But this return a string (delimited by the delimter), not a list.
Actually, the missing part is, after format as text… exactly like I show you into the reply… :split by (create a new list from the formatted text string) with the | as delimiter. So this will return a list of TEXT (duration). You need to convert to number and after, do average

You haven’t split the text by | to turn it back into a list…

Yes this is fine and I should add this to my reply first time

Hmm, I think I follow…

What I have is:

Which is

  1. Is this correct? Or what mistakes have I made?

  2. I don’t understand the use of the delimiter - how is that different from the split by?

I have both:


  1. Regarding Each item converted to a number - what am I doing here? From what you wrote, it seems like I might have created a string(?) of numbers, separated by |, but that bubble reads those numbers as text until this Each item converted to a number instruction?
    Or am I mistaken and something else is happening?


format as text take a list, format it, and join with the delimiter. So a list is now a string with a delimiter. Not a list. This is why you need to use split by after to get the list again.
split by with split it into a list of text. This is why you need to convert it to number to be able to have math operator like :average.

I think everything is ok. Did you test it?

1 Like

So, you seem to be saying that a string is not a list, but putting a split by instruction turns a string into a list…?
Also, what is a string for, and why not just make a list rather than a string if a list is required…?

Thanks for your help with this, A

Of course a string is not a list (a string is a string)…

And yes, split by ‘splits’ a string (by whatever character(s) you define) into a list (of strings - hence the need to convert that list into a list of numbers to perform further numeric operations).

You are making a list (by using the split by operator).

1 Like

Thanks, appreciated, have learnt something, A


Thanks, it seems to work! Brilliant, appreciated :slight_smile:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.