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

Calculate age in years and days

Hi everyone, 

 

I am making an animated dashboard throughout time. And I want to show the age in years and days at the date which is shown in the dashboard. 

 

I've tried several things, and this is the closest I've come:

 

ROUND(DATEDIFF(SELECTEDVALUE(Client[DateOfBirth]), MAX(Date[Date]), DAY)/365.25, 2) &" year" & " "&
ROUND(ROUND(DATEDIFF(SELECTEDVALUE(Client[DateOfBirth]), MAX(Date[Date]), DAY)/365.25, 2) - INT(YEARFRAC(SELECTEDVALUE(Client[DateOfBirth]), MAX(Date[Date]))),1) * 100 * 3.6525 &" days"

Leeftijd in jaar en dagen.jpg
First, the number of days is incorrect. For example the first one should be 169 days instead of 146. Secondly, I don't want to have decimal points for days (I have chosen for 1 and 2 digits for the ROUND-function, because the output of days would be '0' or '365.25').
 
I hope someone could help me with this 🙂
 
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

It is solved! I needed the function MOD for this, to calculate the remainder of the days. So the function will be as follows:

ROUND(DATEDIFF(SELECTEDVALUE(Client[BirthOfDate]), MAX(Date[Date]), DAY)/365.25, 0) &" years" & " and "&
ROUND(MOD(DATEDIFF(SELECTEDVALUE(Client[BirthOfDate]), MAX(Date[Date]), DAY), 365.25), 0) &" days"

View solution in original post

1 REPLY 1
Anonymous
Not applicable

It is solved! I needed the function MOD for this, to calculate the remainder of the days. So the function will be as follows:

ROUND(DATEDIFF(SELECTEDVALUE(Client[BirthOfDate]), MAX(Date[Date]), DAY)/365.25, 0) &" years" & " and "&
ROUND(MOD(DATEDIFF(SELECTEDVALUE(Client[BirthOfDate]), MAX(Date[Date]), DAY), 365.25), 0) &" days"

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.