Forum Discussion
Dataflow DataFormat.Error: We couldn't parse the input provided as a DateTime valu
Hi,
I am trying to create a dataflow but at the end I get the We couldn't parse the input provided as a DateTime value. Details Reason = DataFormat.Error Detail = 13/11/2023 02:00:00 error.
Source = Folder.Files("\Folder Path\PowerBI Datasources"),
Navigation = Source{[#"Folder Path" = "\Folder Path\PowerBI Datasources", Name = "DataName.csv"]}[Content],
#"Imported CSV" = Csv.Document(Navigation, [Delimiter = ",", Columns = 9, Encoding = 65001, QuoteStyle = QuoteStyle.None]),
#"Promoted headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars = true]),
#"Changed column type" = Table.TransformColumnTypes(#"Promoted headers", {{"DateTime", type datetime}, {"Name", type text}, {"Country", type text}, {"Location", type text}, {"Type", type text}, {"Remarks", type text}, {"Latitude", type number}, {"Longitude", type number}, {"Precipitation_mm", type number}}),
#"Duplicated column" = Table.DuplicateColumn(#"Changed column type", "DateTime", "DateTime - Copy"),
#"Changed column type 1" = Table.TransformColumnTypes(#"Duplicated column", {{"DateTime", type date}, {"DateTime - Copy", type time}}),
#"Sorted rows" = Table.Sort(#"Changed column type 1", {{"DateTime", Order.Descending}})
in
#"Sorted rows"
- Anonymous2 years ago
Hi higgy7
Try editing the "Changed column type" step to add the locale information at the end, as highlighted in below code. This should work.
let
Source = Folder.Files("\Folder Path\PowerBI Datasources"),
Navigation = Source{[#"Folder Path" = "\Folder Path\PowerBI Datasources", Name = "DataName.csv"]}[Content],
#"Imported CSV" = Csv.Document(Navigation, [Delimiter = ",", Columns = 9, Encoding = 65001, QuoteStyle = QuoteStyle.None]),
#"Promoted headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars = true]),
#"Changed column type" = Table.TransformColumnTypes(#"Promoted headers", {{"DateTime", type datetime}, {"Name", type text}, {"Country", type text}, {"Location", type text}, {"Type", type text}, {"Remarks", type text}, {"Latitude", type number}, {"Longitude", type number}, {"Precipitation_mm", type number}}, "en-GB"),
#"Duplicated column" = Table.DuplicateColumn(#"Changed column type", "DateTime", "DateTime - Copy"),
#"Changed column type 1" = Table.TransformColumnTypes(#"Duplicated column", {{"DateTime", type date}, {"DateTime - Copy", type time}}),
#"Sorted rows" = Table.Sort(#"Changed column type 1", {{"DateTime", Order.Descending}})
in
#"Sorted rows"Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
5 Replies
- AnonymousNot applicable
Hi higgy7
Try editing the "Changed column type" step to add the locale information at the end, as highlighted in below code. This should work.
let
Source = Folder.Files("\Folder Path\PowerBI Datasources"),
Navigation = Source{[#"Folder Path" = "\Folder Path\PowerBI Datasources", Name = "DataName.csv"]}[Content],
#"Imported CSV" = Csv.Document(Navigation, [Delimiter = ",", Columns = 9, Encoding = 65001, QuoteStyle = QuoteStyle.None]),
#"Promoted headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars = true]),
#"Changed column type" = Table.TransformColumnTypes(#"Promoted headers", {{"DateTime", type datetime}, {"Name", type text}, {"Country", type text}, {"Location", type text}, {"Type", type text}, {"Remarks", type text}, {"Latitude", type number}, {"Longitude", type number}, {"Precipitation_mm", type number}}, "en-GB"),
#"Duplicated column" = Table.DuplicateColumn(#"Changed column type", "DateTime", "DateTime - Copy"),
#"Changed column type 1" = Table.TransformColumnTypes(#"Duplicated column", {{"DateTime", type date}, {"DateTime - Copy", type time}}),
#"Sorted rows" = Table.Sort(#"Changed column type 1", {{"DateTime", Order.Descending}})
in
#"Sorted rows"Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!- higgy7Advocate II
Thank you very much, this has worked!
Would you have a link to any documentation on this or a link to any further information as i was not aware of this.
- AnonymousNot applicable
Actually this locale info can be added to the code by "Change type Using Locale" automatically. However as this error already happened, adding a subsequent new step to change its type using locale won't fix the existing error in previous step. So the solution is to edit the step where the error occurs. You can also remove that error "Changed column type" step from the Applied Steps Pane, then change data types for columns manually using locale. The key is to change the data type correctly at the initial first "changed type" step.