Forum Discussion
doctornick0
7 years agoFrequent Visitor
Add column to convert source name to date
Hi, everybody, When importing a folder of CSV files, I need to add a column to convert the file names (which are in my Source.Name column in Power Query) to dates, as the CSV files are snapshot f...
- 7 years ago
Yes: You add a custom column with this code:
Text.Start(Text.AfterDelimiter([Column1], "_"),2)
Replace "Column1" with the name of your column.
You can paste this code into the advanced editor and see how it works:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkhMTlUISi3ILypRcEksSYw3MDUwNbTQSy4uU4rVgchrQ+S1IfKGRoYw+VgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Day", each Text.Start(Text.AfterDelimiter([Column1], "_"),2)) in #"Added Custom"
ImkeF
Community Champion
7 years agoYes: You add a custom column with this code:
Text.Start(Text.AfterDelimiter([Column1], "_"),2)
Replace "Column1" with the name of your column.
You can paste this code into the advanced editor and see how it works:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkhMTlUISi3ILypRcEksSYw3MDUwNbTQSy4uU4rVgchrQ+S1IfKGRoYw+VgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Day", each Text.Start(Text.AfterDelimiter([Column1], "_"),2))
in
#"Added Custom"doctornick0
7 years agoFrequent Visitor
Thank you so much, this worked perfectly!