Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

dynamically age group

I have a measure that calculates the age dynamically considering  the date selected by the user. but I can't group the results. the simplest solution would be to calculate the age in a column calculated to today but this is no solution as my user may want to select dates in the past and the age must be in relation to the selected date

 

formula dax calculate age

 

 

age = VAR Birthdate = table[Date of birth]
VAR ThisDay = MAX('Calendar'[Date])
VAR IntBirthdate = YEAR ( Birthdate ) * 10000 + MONTH ( Birthdate ) * 100 + DAY ( Birthdate )
VAR IntThisDay = YEAR ( ThisDay ) * 10000 + MONTH ( ThisDay ) * 100 + DAY ( ThisDay )
VAR Age = QUOTIENT ( IntThisDay - IntBirthdate, 10000 )
VAR CheckedAge = DIVIDE ( Age, NOT ISBLANK ( Birthdate ) )
RETURN
CheckedAge

 

 

range age 

range ageorder 
<=201
21-302
31-403
41-504
51-605
60+6

 

thank you very much

2 Replies