Example: Script mapping

example-script-mapping.md
Raw file

The Age breakdown uses the RequestedItem.Age.Days script to calculate the age of incidents in days and map the values to the RequestedItem Age Ranges bucket group.

In the first two images, you see the Age breakdown, which uses the RequestedItem.Age.Days breakdown source and the RequestedItem.Age.Days script for breakdown mapping. You also see that the breakdown source refers to the RequestedItem Age Ranges (Days) bucket group.

[Omitted image "age-breakdown.png"] Alt text: The age breakdown with Requested Item.Age.Days source and mapping highlighted.

[Omitted image "incident-age-days-bkdown-source.png"] Alt text: The Incident.Age.Days breakdown source showing the Incident Age Ranges bucket group

The RequestedItem.Age.Days script takes the timestamp when the incident was opened from the incident table. The script subtracts this time from the timestamp at the end of the collection period. The script converts this value from milliseconds to days.

JavaScript
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, score_end);

The resulting numbers of days are sorted into the buckets of the bucket group.

[Omitted image "incident-age-ranges-bucket-group.png"] Alt text: Incident Age Ranges bucket group buckets

Here is the result of running this script on the Number of open incidents indicator.

[Omitted image "detailed-scorecard-age-breakdown.png"] Alt text: KPI Details for the Number of open incidents indicator showing the Age breakdown.

Parent Topic:Create a breakdown mapping on a breakdown record

Related topics

Scripting in Performance Analytics

Search documentation
Search document titles and file paths on the australia branch