Forum Discussion
calculate Date & Time differance
- 1 year ago
Hi MEHUL123
Why does it have to be done in DAX? It's much easier in Power Query. DAX doesn't have the functions to do this type of calculation easily.
In Power Query just subtract the first column from the 2nd. You can then convert the result to a Duration data type and then calculate minutes from the hours and mins (and days if you have any)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjbUNTTQNTIwMlEwMrYyNbUyMFDSUTIAihpCRA3NrQzMQKKxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetime}, {"Column2", type datetime}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [Column2]-[Column1]), #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type duration}}), #"Added Custom1" = Table.AddColumn(#"Changed Type1", "Minutes", each Duration.Hours([Custom]) * 60 + Duration.Minutes([Custom])), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"}) in #"Removed Columns"Regards
Phil
- Anonymous1 year ago
Hi,
Thanks for the solution PhilipTreacy offered, and i want to offer some more information for user to refer to.
hello MEHUL123 , you can create a calculated column like the following.
Column = DATEDIFF([Column1],[Column2],MINUTE)Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for the solution PhilipTreacy offered, and i want to offer some more information for user to refer to.
hello MEHUL123 , you can create a calculated column like the following.
Column = DATEDIFF([Column1],[Column2],MINUTE)
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.