Reputation: 1599
is there any way to combine each "day", "month", and "year", "hour" column into a datetime column in Power BI? I googled and binged alot, and i even tried many like :
https://community.powerbi.com/t5/Desktop/Create-Date-column-Power-Query-Power-BI/m-p/1699007#M674427
I know there is a DAX that I can just DATE(Year, month, date) but this is only date, I want Datetime format.
Would anyone please help?
Upvotes: 1
Views: 3697
Reputation: 4282
Please try like this
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlTSUTIyARKWIIYxkDAG8YyNlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [year = _t, day = _t, month = _t, hour = _t, minute = _t, second = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"year", Int64.Type}, {"day", Int64.Type}, {"month", Int64.Type}, {"hour", Int64.Type}, {"minute", Int64.Type}, {"second", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each #datetime([year],[month],[day],[hour],[minute],[second])),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetime}})
in
#"Changed Type1"
Upvotes: 2