cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Birthday in human readable language

@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
Highlighted
Solution Sage
Solution Sage

Re: Birthday in human readable language

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.

Highlighted
Regular Visitor

Re: Age in human readable language

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.

Highlighted
Microsoft
Microsoft

Re: Birthday in human readable language

@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

Highlighted
Regular Visitor

Re: Birthday in human readable language

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

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors