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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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