How to calculate the average age from a list of users based on their birthdates

Hello.
I have a list of users, and each of them has a field - date of birth (type Date). What I need to achieve - is to calculate the average age of users. As far as I know Bubble does not have a method map for the list, for me to get the list of user’s age, from which I’ll be able to get average age. I know how to calculate an age for a single user based on their date of birth, but how to implement it for the list in order to get a list of ages? Could not find any solution

User's age = Current date time - User’s date of birth:format as years

List of user's ages = List of user’s:format as text[User's age with delimiter of #]:split by #:each item converted to number

Average age = List of user's ages:average

2 Likes

Thank you @georgecollier. My only comment to your solution is that for calculating User’s age “format as years” is not available as an option. So I used “…:formatted as days” / 365) :floor

Oh, really? I swear I’ve seen it before… good you’ve found a solution.

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