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

script to determine lead time

kwilson1
Kilo Contributor

Hi Community,

I am VERY novice at creating metrics in PA but getting there so please bear with.   Here is what I need help with.   I need to metric change lead time.   I think I need to create scripts to calculate the time between create date and planned start date of a change record.   I need to then group those times into buckets, 0 days, 1 days, 2 days, 3-7 days, 1-2 weeks, and greater than 2 weeks.   I need to put those in a stacked graph for each month for the last year.

So at the end my graph will show the 6 different lead times stacked by into my total changes for the month over 12 months.   I believe there is some scripting involved.

HELP!!

1 ACCEPTED SOLUTION

Vincent Loffel1
Kilo Guru

Hi Kerry,



The script you are looking for is already delivered out of the box, well at least for the biggest part.


Take a good look at the age days script for changes. As you can see this script detracts the created date from the score end (placeholder for time when job runs) and ruturns the value in days.



So you need to modify this script into something like this:


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


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


days(current.opened_at, start_date)


Make sure you have the planned start date field selected in the Source section of the script!



Than create your buckets with start and end values in days. So 0 days has a start value of 0 and an end value of 1, 1 days has a start value of 1 and an end value of 2, etc.



Then create a breakdown source and select buckets as factstable with a filter applied to select only your custom buckets


Now create a breakdown with the source you just created and in the breakdownmapping select the script you just created.



Cheers,


Vincent


View solution in original post

5 REPLIES 5

Hi Keri,



Good to hear! Could you please mark the answer as correct, so other users can quickly find the answer to similar questions?


Thanks.



Vincent