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
EricKautz
Helper I
Helper I

Creation of a Timestamp (HH:MM) from Text

I have an excel report that I want to pull timing data from. Unfortunately the column of data that has the time is in a text format below:

1hr 3min
0hr 23min
0hr 23min)

 

doing a text.remove won't help as it will combine all the numbers together and won't be able to differentiate which numbers are the hours and minutes. Right function would work for minutes, but can't for hours as that number can be infinite. How can I get the data from the above reference into a formatted timestamp (01:03, 00:23, etc)

1 ACCEPTED SOLUTION
Chewdata
Super User
Super User

if the ) at the end is accidental, then you can use this.
1. remove the min
2. split column on "hr "
3. combine into a timeformat.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMswoUjDOzcxTitWJVjIAcoyw8WIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","min","",Replacer.ReplaceText,{"Time"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "Time", Splitter.SplitTextByDelimiter("hr ", QuoteStyle.Csv), {"Hours", "Minutes"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Hours", Int64.Type}, {"Minutes", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Timestamp", each #time([Hours],[Minutes],0), type time)
in
#"Added Custom"

View solution in original post

2 REPLIES 2
Chewdata
Super User
Super User

if the ) at the end is accidental, then you can use this.
1. remove the min
2. split column on "hr "
3. combine into a timeformat.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMswoUjDOzcxTitWJVjIAcoyw8WIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","min","",Replacer.ReplaceText,{"Time"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "Time", Splitter.SplitTextByDelimiter("hr ", QuoteStyle.Csv), {"Hours", "Minutes"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Hours", Int64.Type}, {"Minutes", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Timestamp", each #time([Hours],[Minutes],0), type time)
in
#"Added Custom"

HotChilli
Super User
Super User

replace 'hr ' with':'

Remove the 'min'.

Add a zero at the front if required. Then construct a #time or convert to the appropriate type

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