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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
bwelsh
Helper I
Helper I

Convert Text to Hours

I have a colum that has duration as a text string "15 Hours, 48 Minutes". Is it possible to covert this to a decimal hour?

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @bwelsh,

 

Could you please mark the proper answer as solution or share the answer if it's convenient for you? That will be a help to the others.

 

Best Regards!
Dale

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

My interpretation is that you want 15.8 as a result.

 

In Power Query it can be done by taking the part before the first space, convert this to a number and take the part between the second and the third space, convert this to a number, divide by 60 and add to the first number.

 

Example code from Power Query - Advanced Editor:

 

let
    Source = #table(1,{{"15 Hours, 48 Minutes"}}),
    TextToHours = Table.TransformColumns(Source, {{"Column1", each Number.From(Text.BeforeDelimiter(_," "))+Number.From(Text.BetweenDelimiters(_, " ", " ", 1, 0))/60, type number}})
in
    TextToHours

 

Specializing in Power Query Formula Language (M)

Helpful resources

Announcements
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.