The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Trying to create a monthly average duration using performance analytics

david_myers
Tera Contributor

I have existing metrics that calculate duration and business duration of certain scripted conditions.   I would like performance analytics to help calculate averages and provide charts to visualized these indicators.  

For example, The metric is Release Task Lead time.   Start is defined as when the Approval field is marked 'Approved'.   End is defined as when the State changes to WIP.   The metric is already established and collecting data.   Business Duration is calculating based on a certain business schedule.  

Since the metrics already have the data I would like to use Performance Analytics.   Goal is to have the Average Business Duration of these Lead time metrics, monthly.  

i have created Automated Indicators to collect the count of any metric instance where the Value is 'Lead Time'.   I have the sum of each instance for the past 6 months.  

Now I need to collect the total duration of these instances for each month, which I will then use a formula indicator to calculate the average.  

The problem I am running into is trying to get a SUM of the Business Duration field values.   I am unsure how to gather this data.   I have setup my automated indicator but it's returning zero values.  

Can anyone give me some direction on how to accomplish my goal?  

1 ACCEPTED SOLUTION

Ok, well unless the business_duration field contains the number of miliseconds, this script is not going to work.


Out of the box the field business_duration is an duration field (datetime). To get the number of days back you first need to retrieve the fields content in miliseconds.


It will probably work if you create the script like this


var days=function(x) {


        return x.dateNumericValue()/(24*60*60*1000);


};


days(current.business_duration);


View solution in original post

6 REPLIES 6

Vincent Loffel1
Kilo Guru

Hi David,



Create a summation like you did, but instead of selecting a field use a script.


Build a script that uses the business duration field and recalculates it to days. (See the OOTB scripts for examples on how to do that)


Return the result and that should do it.



Cheers,


Vincent


I have created scripts using the OOB as a guide but now I'm encountering errors in the job collection.   In the source section of the script I indicate the table and field to be used in the script.   Any idea why it's returning this error? I also see it's returning similar errors in other job logs where we utilize similar scripts.



Error during JavaScript evaluation: Not all references of "current" are passed in by "arguments" script: var days=function(x){return x/(24*60*60);};


days(current.business_duration);



Metric [metric_instance]
Fields:   Business duration.

Hi David,



The job throws this error if there is a mismatch between the fields you use in the script and the fields that you've selected in the source section.


Could you please create a screenshot of the script?



Thanks,


Vincent


Sure, here it is.   Thanks for your help!


12-15-2015 11-40-56 AM.jpg