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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Converting years and months to time data type

i am looking to see if there is a simple way to convert values like the following 0 Yrs 7 Mths into actual time so i can start calculating averages etc

7 REPLIES 7
mahoneypat
Microsoft Employee
Microsoft Employee

Here is an expression you can use in a custom column to convert your text yrs and months to the # of months, for example.  Replace [TimeInYrsMos] with your actual column name.

 

= let numberlist = List.RemoveNulls(List.Transform(Text.Split([TimeInYrsMos], " "), each try Number.FromText(_) otherwise null)) in numberlist{0}*12 + numberlist{1}

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


PhilipTreacy
Super User
Super User

Hi @Anonymous 

You could convert to a duration in days/h/m/s but how do you convert 0 Yrs 7 Mths to a date?  You'll need to supply some examples of your desired results.

Thanks

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

@PhilipTreacy i am looking for a duration, but was hoping i could do duration by years and months which i am guessing i can not do that?

Fowmy
Super User
Super User

@Anonymous 

Refer to below article from REZA and modify as per your need: https://radacad.com/calculate-duration-in-days-hours-minutes-and-seconds-dynamically-in-power-bi-using-dax

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fowmy
Super User
Super User

@Anonymous 

 

Can you provide some examples with the desired results?

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

 

 

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy  ideally formatted as a time data type. 00:00:00 so year/months/days. That way i can look at averages/totals

I don't think you will be able to do averages/totals with year/month/days in that format.  How about just using days or months in decimal form?  Your initial example didn't have days in it, but your last post did.  Is your data in this format  0 yrs 6 mos 11 days ?

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors