performance analytics - calculate time difference

amanimogili
Kilo Contributor

Hi,

We have two fields "Start time" and "Mitigation time" on Incident form. The difference between these two will be taken as "Hours of Impact" and we have to show the same using Performance Analytics module.

Using PA, we have to show the hours of impact for all incidents. I have gone through all the indicators and observed this cannot be done even by Formula Indicators. Since Formula Indicators will be applied between two different indicators.

Can we use Metrics to calculate the difference and create database view on both metric and Incident and call it in Indicator. Is this advisable or is there any other way.

Could anyone provide suggestion.

Thanks in Advance!

Regards,

Amani

1 ACCEPTED SOLUTION

gertjankrab
ServiceNow Employee
ServiceNow Employee

Hi Amani,



I think you should create an Indicator like the OOTB Indicator "Summed duration of resolved incidents" which is using a script to calculate the difference in Hours. See the script below.



var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};


var hours=function(x,y){return diff(x,y)/(60*60*1000);};


hours(current.opened_at, current.resolved_at);



Regards,



Gertjan


View solution in original post

1 REPLY 1

gertjankrab
ServiceNow Employee
ServiceNow Employee

Hi Amani,



I think you should create an Indicator like the OOTB Indicator "Summed duration of resolved incidents" which is using a script to calculate the difference in Hours. See the script below.



var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};


var hours=function(x,y){return diff(x,y)/(60*60*1000);};


hours(current.opened_at, current.resolved_at);



Regards,



Gertjan