Forum Discussion
smpa01
5 years agoCommunity Champion
Calculated datetime column in Power Query not DAX
My source data is following let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t ...
- 5 years ago
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetime}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.DateTimes( [Column1], 24, #duration(0, 1, 0, 0))), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Duplicated Column" = Table.DuplicateColumn(#"Expanded Custom", "Custom", "datetime"), #"Changed Type2" = Table.TransformColumnTypes(#"Duplicated Column",{{"Column1", type date}, {"Custom", type time}, {"datetime", type datetime}}) in #"Changed Type2"
CNENFRNL
5 years agoCommunity Champion
Date and Time can be directly concatenated by "&" operator; thus, create a series of hours by List.Times,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ1ACGlWB0krpFSbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Added Times" = Table.AddColumn(#"Changed Type", "Time", each List.Times(#time(0, 0, 0), 24, #duration(0, 1, 0, 0))),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Times", "Time"),
#"Concatenated DateTime" = Table.AddColumn(#"Expanded Custom", "DateTime", each [Date] & [Time])
in
#"Concatenated DateTime"