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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Chris2016
Resolver I
Resolver I

Calculate the average employee tenure in months for latest role

Hello,

Could you please help with the following issue? I have to calculate the average of employee tenure in months for latest role in a table where each individual has multiple rows for role date start.

NameCompanyStartDateRoleDateTime_Months in latest Role_Employee Tenure
A11/9/2020 0:0012/1/2021 0:0053-6 Months
A11/9/2020 0:006/30/2022 0:0053-6 Months
A11/9/2020 0:008/15/2022 0:0053-6 Months
A11/9/2020 0:0011/11/2022 0:0053-6 Months
B7/5/2021 0:0012/1/2021 0:0076-12 months
B7/5/2021 0:009/1/2022 0:0076-12 months
B7/5/2021 0:009/12/2022 0:0076-12 months
C3/1/2021 0:0012/1/2021 0:0096-12 months
C3/1/2021 0:007/4/2022 0:0096-12 months
D12/27/2021 0:006/14/2022 0:00106-12 months
F10/4/2021 0:0010/4/2021 0:001312-24 Months
F10/4/2021 0:003/1/2022 0:001312-24 Months


I calculated the employee's months in role for their latest role start, but how can I calculate the average for the entire table?

_Months in latest Role = 
var currDate = CALCULATE(MAX([RoleDateTime]), ALLEXCEPT('Table', 'Table'[Name]))
return  ABS ( DATEDIFF ( currDate, TODAY (), MONTH ) )

The average in the above table should be 8.8, but how can I calculate it in DAX?

Thanks a lot for any help!

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Chris2016 

try to plot a measure like:

Measure = 
AVERAGEX(
    VALUES(TableName[Name]),
    CALCULATE(AVERAGE(TableName[_Months in latest Role]))
)

 

it worked like:

FreemanZ_0-1680880324660.png

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Chris2016 

try to plot a measure like:

Measure = 
AVERAGEX(
    VALUES(TableName[Name]),
    CALCULATE(AVERAGE(TableName[_Months in latest Role]))
)

 

it worked like:

FreemanZ_0-1680880324660.png

 

Hi, @FreemanZ ,

Thanks so much for the fast reply, the measure works!

Chris2016_0-1680882290362.png

 



Best regards!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.