Forum Discussion
Anonymous
8 years agoNot applicable
Calculating Age on a Given Date
Hi, I have a table with client details, including date of birth, how would I go about calculating the age of these clients on any given date (Which the end user can select). The aim of the exerci...
- 8 years ago
Anonymous
My apologies for late reply
You can first create a small parameter table defining your age buckets for example
Bucket Age End Age Start Infant 2 0 Teenager 20 2 Adult 60 20 Senior Citizen 200 60 Then you can use a MEASURE like this
Measure = VAR AgeStart = SELECTEDVALUE ( Buckets[Age Start] ) VAR AgeEnd = SELECTEDVALUE ( Buckets[Age End] ) RETURN COUNTROWS ( FILTER ( VALUES ( Table1[Client Name] ), [BirthDate1] > AgeStart && [BirthDate1] <= AgeEnd ) )[BirthDate1] is the Measure we created before
Please see the attached file for clarity
Zubair_Muhammad
Community Champion
8 years agoAnonymous
My apologies for late reply
You can first create a small parameter table defining your age buckets for example
| Bucket | Age End | Age Start |
| Infant | 2 | 0 |
| Teenager | 20 | 2 |
| Adult | 60 | 20 |
| Senior Citizen | 200 | 60 |
Then you can use a MEASURE like this
Measure =
VAR AgeStart =
SELECTEDVALUE ( Buckets[Age Start] )
VAR AgeEnd =
SELECTEDVALUE ( Buckets[Age End] )
RETURN
COUNTROWS (
FILTER (
VALUES ( Table1[Client Name] ),
[BirthDate1] > AgeStart
&& [BirthDate1] <= AgeEnd
)
)
[BirthDate1] is the Measure we created before
Please see the attached file for clarity
Anonymous
8 years agoNot applicable
Thanks @Zubair_Muhammad, don't need to apologies, I'm slower in responding.
Your solution worked, thanks!