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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not 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 exercise is to see the age demographics on any given date in the past.

 

Thanks

1 ACCEPTED SOLUTION

@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

aged.png



Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

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 filter on). the aim of the exercise is to see the age demographics on any given date in the past.

 

Thanks

@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

aged.png



Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Thanks @Zubair_Muhammad, don't need to apologies, I'm slower in responding.

 

Your solution worked, thanks!

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Hi Mohit

 

You can create a Calendar Table for selecting dates

Then you can use one of these MEASURES to get the age at a specified date

 

Please see the attached file as well

 

BirthDate1 =
YEARFRAC ( SELECTEDVALUE ( Table1[BirthDate] ), MAX ( 'Calendar'[Date] ) )
BirthDate2 = INT(YEARFRAC(SELECTEDVALUE(Table1[BirthDate]),MAX('Calendar'[Date])))


Bdays.png


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

Thanks Zubair, that works perfectly. However my conundrum is that I am unable to use this measure to graph out frequency of each age?

 

Also how would I go about grouping these ages in to buckets of 5 or distinct age groups like infant, teenager, adult, senior citizen, etc.

 

Thanks so much for the help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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