The previous examples refer to special metrics, kpis and now variables and make use of some aggregation, prediction and breakdown functionality that hints at greater capabilities. To discuss these we need to look at how ServiceClarity interprets your KPI formula and at the underlying scripting object model that ServiceClarity provides. Your KPI formula are treated as sandboxed javascript functions with three input variables:

  1. metrics - an Argument object that can contain zero, one or more lists of metric data
  2. kpis - an Argument object that can contain zero, one or more lists of KPI data
  3. now - a Calculation Date object that represents the date and time when the KPI is calculated for, nominally this is 'now' but is could be date in the past.

Arguments:

Which metrics and KPIs are available to the calculation depends on how the KPI parameters are configured. It is common to have no KPIs or no metrics, a single metric or KPI or a collection of both. For this reason the Arguments object provides functions to pick out individual metrics/KPIs or filter sets of them. It also provides functions for finding the latest or first time values and additional checks for missing values. A detailed description of the functionality provided by the Arguments object can be found in the Reference section of this document.

Calculation Date:

KPI calculations are made for a specific date and time. Normally this date and time will be time at which the calculation is run but if a KPI is (re)calculated for past dates the date value of the now variable will reflect the historic date of the calculation and the time will always be set to 23:59:59 - the last moment of the day. This is because only one value can be stored for a KPI for a given date and the last time stamp always overrides a previous one. 

As illustrated in the examples from the previous section the now variable has a number of useful functions for defining date ranges that can be used in filters and prediction calculations. A detailed description of the functionality provided by the Calculation Date object can be found in the Reference section of this document.

Outputs:

The output of your KPI javascript functions can be:

  1. undefined - There is no requirement to return anything as not all KPIs have a value for all dates.
  2. numeric value - the value for the KPI on the date defined by now
  3. object - a simple javascript object that contains the properties:
  • value for the KPI on the date, the 
  • breakdown for the KPI and optionally a numeric 
  • sample size for cases where aggregations can be affected by the significance of the input data. 
Did this answer your question?