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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Chelena
Regular Visitor

Birthday in human readable language

Good day

 

I'm a nurse working with with paediatric data. I want the column to display age  "2y; 1m; 4d" from age in days. My excel recipe for this is as follows, it works fine:

=INT([@Age]/365.2425)&"y; "
& INT(([@Age]-INT([@Age]/365.2425)*365.2425)/30.44)&"m; "
&INT([@Age]-INT([@Age]/365.2425)*365.2425-INT(([@Age]-INT([@Age]/365.2425)*365.2425)/30.44)*30.44)&"d"

 

I tried to do the following and it failed:

Int64.From([Age]/365.2425)&"y; "
& Int64.From(([Age]-Int64.From([Age]/365.2425)*365.2425)/30.44)&"m; "
&Int64.From([Age]-Int64.From([Age]/365.2425)*365.2425-Int64.From(([Age]-Int64.From([Age]/365.2425)*365.2425)/30.44)*30.44)&"d"

 

I will add the solution to my personal cookbook because I use it repeatedly for all sorts of dates.

 

Thank you for your time!

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Chelena,

Directly create a calculated column using DAX below.

col = INT([Age]/365.2425)&"y; "
& INT(([Age]-INT([Age]/365.2425)*365.2425)/30.44)&"m; "
&INT([Age]-INT([Age]/365.2425)*365.2425-INT(([Age]-INT([Age]/365.2425)*365.2425)/30.44)*30.44)&"d"


1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Chelena,

Directly create a calculated column using DAX below.

col = INT([Age]/365.2425)&"y; "
& INT(([Age]-INT([Age]/365.2425)*365.2425)/30.44)&"m; "
&INT([Age]-INT([Age]/365.2425)*365.2425-INT(([Age]-INT([Age]/365.2425)*365.2425)/30.44)*30.44)&"d"


1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Lydia @v-yuezhe-msft ! I must still get use to the BI interface. I was trying to do it by editing the query / Power Query because I'm more familiar with it. I didn't think of the modeling ribbon.

 

But if there is anybody out there that can solve this in (power) query, it will be appreciated.

 

Thank you for your time Lydia. I will use it a lot and in future and try and remember the modeling ribbon. Smiley Very Happy

rajulshah
Resident Rockstar
Resident Rockstar

Hello @Chelena,

 

From the description, I think you want to display age in days.

 

For that, you just have to add custom column in the table in 'Edit Queries' window.

 

Select the Dates column and click on 'Add Column' tab and click on 'Column from Examples', and under that option select 'From Selection'.custom column.png

You will get list of values you want to calculate. You can select age and will have age in days.

 

custom column.png

 Let me know if I missed something or need any further help.

 

Regards.

Thank you for your response @rajulshah.

 

I do have the age in days that I derived from Add column --> Date --> Age. I want to convert that age in days (766) to this:

"2y; 1m; 4d"

 

Thank you.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.