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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

convert Number to Minutes format

Hi all,

 

I have data like Hour Spent Field. how can I change into Minutes format? 

 

Hours SpentMinutes
00
0.055
0.11
0.6565
0:4545
160
1.1575
14:05845
14.05845
14.65905
14:65905
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Please check the followig steps as below.

 

1. Replace all "." to ":" in Hours Spent column in power query.

 

2. Split columns by ":" here is the M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlDSAeJYHSBLz8AUyDGFcgyBbEMo2wwkYQaVsTIB8UwgPJAqM4h+Qz1DkIQ5VMLECmycBUyhiR46H2yqpQFcPYIfCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Hours Spent" = _t, Minutes = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hours Spent", type text}, {"Minutes", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",".",":",Replacer.ReplaceText,{"Hours Spent"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "Hours Spent", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Hours Spent.1", "Hours Spent.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Hours Spent.1", Int64.Type}, {"Hours Spent.2", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Hours Spent.1", "Hours"}, {"Hours Spent.2", "Mins"}})
in
    #"Renamed Columns"

3. To create a calcualted column as we need.

 

Minu = Table1[Hours]*60+Table1[Mins]

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Please check the followig steps as below.

 

1. Replace all "." to ":" in Hours Spent column in power query.

 

2. Split columns by ":" here is the M code for your reference.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlDSAeJYHSBLz8AUyDGFcgyBbEMo2wwkYQaVsTIB8UwgPJAqM4h+Qz1DkIQ5VMLECmycBUyhiR46H2yqpQFcPYIfCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Hours Spent" = _t, Minutes = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hours Spent", type text}, {"Minutes", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",".",":",Replacer.ReplaceText,{"Hours Spent"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "Hours Spent", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Hours Spent.1", "Hours Spent.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Hours Spent.1", Int64.Type}, {"Hours Spent.2", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Hours Spent.1", "Hours"}, {"Hours Spent.2", "Mins"}})
in
    #"Renamed Columns"

3. To create a calcualted column as we need.

 

Minu = Table1[Hours]*60+Table1[Mins]

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Greg_Deckler
Super User
Super User

I think you just need to multiply by 60, looks like a fractional hour. You first few Minutes values seem to be incorrect.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors