Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Format 0mm.year to a date

Hi all, 

 

new user here having a headace in Power Query. In my data I have the date in a stupid format for example January 2022 is "001.2022". How do I format the column to be able to make it a date column?

 

 

Br Tapio

 

  • Anonymous I used Column from Examples and then converted to date, this is the code it produced.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAw1DMyMDJSitUBcYyQOcbIHBNkDliPIZRjiixjBuXEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Added Custom Column" = Table.AddColumn(Source, "Custom", each Text.Combine({Text.Middle([Column1], 2, 1), "/1/", Text.Middle([Column1], 4)}), type text),
        #"Changed Type" = Table.TransformColumnTypes(#"Added Custom Column",{{"Custom", type date}})
    in
        #"Changed Type"

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous I used Column from Examples and then converted to date, this is the code it produced.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAw1DMyMDJSitUBcYyQOcbIHBNkDliPIZRjiixjBuXEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Added Custom Column" = Table.AddColumn(Source, "Custom", each Text.Combine({Text.Middle([Column1], 2, 1), "/1/", Text.Middle([Column1], 4)}), type text),
        #"Changed Type" = Table.TransformColumnTypes(#"Added Custom Column",{{"Custom", type date}})
    in
        #"Changed Type"