Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Vantage111
Frequent Visitor

Find Average age on a given date

I am putting together a simple HR dashboard. One of the measures is Average age when an employee joins:

Average Age = 
Calculate(AVERAGE(AllEmployees[age]),
USERELATIONSHIP(Allemployees[join_date],CalendarTAB[Date]))
This also allows me to visualize the staff ages by year:
Vantage111_0-1684864063759.png

HOWEVER: this is the average age on Join_Date, what I would really like to see is AVERAGE ACTUAL AGE for the year - ie. if I had the same 10 staff working from 2015 to date and they were all 30 when they joined, then the average age will not change and by 2023 it will still show as 30 when in fact the average age should be 38.

I have a dob column, age is calculated using datediff and the Join_Date, I can also get Current_Age using DateDiff and Now(), and I use a date table called CalendarTab.

Hope this makes sense.

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Vantage111 ,

 

You want to use a measure something like this:

 

_avgAgeOverTime =
VAR __maxDate = MAX(CalendarTab[Date])
RETURN
AVERAGEX(
    FILTER(
        employeeTable,
        employeeTable[startDate] <= __maxDate
        && employeeTable[endDate] >= __maxDate
    ),
    DATEDIFF(employeeTable[dob], __maxDate, DAY) / 365.25
)

 

 

You just need to make sure to use a CalendarTab field (Date, Month, Year etc.) as your visual axis to ensure __maxDate gets populated.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @Vantage111 ,

 

You want to use a measure something like this:

 

_avgAgeOverTime =
VAR __maxDate = MAX(CalendarTab[Date])
RETURN
AVERAGEX(
    FILTER(
        employeeTable,
        employeeTable[startDate] <= __maxDate
        && employeeTable[endDate] >= __maxDate
    ),
    DATEDIFF(employeeTable[dob], __maxDate, DAY) / 365.25
)

 

 

You just need to make sure to use a CalendarTab field (Date, Month, Year etc.) as your visual axis to ensure __maxDate gets populated.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors