Robert is right. The easiest Mendix way is a retrieve and loop in a microflow. There is a way however that will give you better performance if need be, and that is OQL. You do a retrieve over the person, select avg((datediff(DAY,dateofbirth, currentdate)) like this:
FROM ForumQuestions.Employee SELECT avg(datediff(DAY, DateOfBirth, '[%CurrentDateTime%]')) as AverageDaysOfOurPersons
And this is also very doable. To use this OQL:
See https://forumquestions-sandbox.mxapps.io/p/questions, click question 96873 for a working sample. and click on the pencil on right side of the screen to view it in Studio (Awesome feature in this usecase). It actually was easier to accomplish then I expected.
Nevertheless, you also want to know how to do this in a microflow and loop, see this shared microflow as example:
Thanks for the answers, i need to use microflow for this, i know how to retrieve a list of the users inside the microflow but i am not sure how to calculate the age in the loop.
Thanks for your help.
The easiest way to do this would be to retrieve all the users and loop over them. You would need to calculate each age in the loop, then add to a total combined age. Outside the loop you would then divide this by the total number of users to get the average (mean) age.
Hope this helps.