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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply

We couldn't parse the input provided as a Time value.

Hello experts,

I have excel file coming from SAP engine not correctly formatted (time displays as a text) see below

(unfortunately, I'm obliged to used it as) 😪

Picture 1Picture 1

So far, when I try to convert above data into time I have this error message: We couldn't parse the input provided as a Time value.

I know it's because the hour value is greater than 23 but I don't know how to deal with.

 

Thank you in advance!

 

Best

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @FranckGbadamass 

 

Download example XLSX file

 

As you point out, these aren't actually times, so how do you want to convert them?  What do they represent?  A duration?

 

If so then you can convert these to durations but it takes several steps to format and convert each part of the data (days, hours, minutes, seconds).

 

let
    Source = "27:41:51",
    #"Imported Text" = Lines.FromText(Source),
    #"Converted to Table" = Table.FromList(#"Imported Text", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Converted to Table", "Column1", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"Column1.1", "Hours_"}, {"Column1.2", "Mins"}, {"Column1.3", "Secs"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Days_", each Text.From(Number.From([Hours_]) /24)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Days", each Text.Split([Days_] ,"."){0}),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Hours", each Text.From(Number.From("." & Text.Split([Days_] ,"."){1}) * 24)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Hours_", "Days_"}),
    #"Added Custom3" = Table.AddColumn(#"Removed Columns", "Duration", each Duration.FromText([Days] & "." & [Hours] & ":" & [Mins] & ":" & [Secs])),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom3",{{"Duration", type duration}})
in
    #"Changed Type"

 

That code will convert this

fr1.png

 

to this

fr2.png

 

My sample code is only working on 1 column, your image shows several columns.  You can combine everything into 1 column to work on it.  If you need help doing that please supply your data file so I can work on it.

 

Regards

 

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!


View solution in original post

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @FranckGbadamass 

 

Download example XLSX file

 

As you point out, these aren't actually times, so how do you want to convert them?  What do they represent?  A duration?

 

If so then you can convert these to durations but it takes several steps to format and convert each part of the data (days, hours, minutes, seconds).

 

let
    Source = "27:41:51",
    #"Imported Text" = Lines.FromText(Source),
    #"Converted to Table" = Table.FromList(#"Imported Text", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Converted to Table", "Column1", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3"}),
    #"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"Column1.1", "Hours_"}, {"Column1.2", "Mins"}, {"Column1.3", "Secs"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Days_", each Text.From(Number.From([Hours_]) /24)),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Days", each Text.Split([Days_] ,"."){0}),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Hours", each Text.From(Number.From("." & Text.Split([Days_] ,"."){1}) * 24)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Hours_", "Days_"}),
    #"Added Custom3" = Table.AddColumn(#"Removed Columns", "Duration", each Duration.FromText([Days] & "." & [Hours] & ":" & [Mins] & ":" & [Secs])),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom3",{{"Duration", type duration}})
in
    #"Changed Type"

 

That code will convert this

fr1.png

 

to this

fr2.png

 

My sample code is only working on 1 column, your image shows several columns.  You can combine everything into 1 column to work on it.  If you need help doing that please supply your data file so I can work on it.

 

Regards

 

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!


Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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