Forum Discussion
Anonymous
4 years agoNot applicable
Calculating Employee Age by Month
Hi Please see link to dummy file below: https://1drv.ms/u/s!AkENRXlfBIJKig49BFN8Y8DQwgJ5?e=v3DW0w I am struggling to create a measure that calculates the age of an Employee at any given date...
TheoC
Community Champion
4 years agoHi Anonymous
I recommend using Power Query to calculate. All you need to do is:
- Go to Add Column
- Click on the Date button
- Click on Age
- Select the new column, then click on Duration button and select the type of duration you want (i.e. Years, Months, Days, etc).
From here, you will have a column that you can manipulate as you require when using DAX.
Otherwise, if you're wanting to use DAX, then you can use the following:
Age (Rounded to Year ) = INT ( YEARFRAC ( EE_Ref[DoB] , EOMONTH ( TODAY () , -1 ) , 1 ) )Age (Not Rounded) = YEARFRAC ( EE_Ref[DoB] , EOMONTH ( TODAY () , -1 ) , 1 )
Hope this helps 🙂
Anonymous
4 years agoNot applicable
Hi Theo
Worth pointing out here that the Power Query method doesn't take account of leap years and is dividing the total number of days by 365 rather than 365.25. Some ages will therefore be incorrect.