Forum Discussion
Anonymous
5 years agoNot applicable
Calculating case age
Hi, I have below columns and would like to create a new column Case Age that willl show days the case is open for. If today is Sep 16 2020 then the Case Age column should show below. If there...
- 5 years ago
Hi Anonymous
and here is my final version:
Measure = VAR _CurrentCreatDateTime = CONVERT(MAX('Table'[CreatDateTime]),DOUBLE) VAR _CurrentCloseDateTime = MAX('Table'[CloseDateTime]) RETURN IF( _CurrentCloseDateTime = BLANK(), INT(CONVERT(NOW(),DOUBLE) - _CurrentCreatDateTime) , BLANK() )With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)
FrankAT
5 years agoCommunity Champion
Hi Anonymous
you can try it very easy with Power Query like this (don't bother with date and time format in figur below, it's localized):
// Table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fcm7DcAgDAXAVZBrJPsZ7Ah3GQCJHrH/GvkVaaK0d3OSsTZWUUkWBVE8jU6ZnKEPA1G3gKS908qTKus78DOvyXSnNIb/rn3vOgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CreatDateTime = _t, CloseDateTime = _t]),
#"Changed Type with Locale" = Table.TransformColumnTypes(Source, {{"CreatDateTime", type datetime}}, "en-US"),
#"Changed Type with Locale1" = Table.TransformColumnTypes(#"Changed Type with Locale", {{"CloseDateTime", type datetime}}, "en-US"),
#"Added Custom" = Table.AddColumn(#"Changed Type with Locale1", "Case Age", each if [CloseDateTime] = null then DateTime.LocalNow() - [CreatDateTime] else null),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Case Age", type number}}),
#"Rounded Off" = Table.TransformColumns(#"Changed Type",{{"Case Age", each Number.Round(_, 0), type number}})
in
#"Rounded Off"
With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)