Median KPI scoring for Performance Analytics

Abdi2k
Tera Contributor
Hi all,

 

Performance Analytics gives us sums and averages out of the box, but not medians. For time-based KPIs that is a real gap: a handful of long-running records can pull an average well above the typical case, while the median stays closer to what most people actually experienced.

 

I built a small, reusable Script Include that fills that gap, and I am sharing it openly in case it saves someone else the effort.

 

What it does
  • Computes the median of a score per indicator and writes it straight into the PA score tables.
  • Supports single breakdown scores and breakdown-pair (matrix) scores.
  • Runs daily or monthly from a single switch.
  • Works with both the legacy pa_scores model and the newer pa_scores_l1 / pa_scores_l2 model (auto-detected from com.snc.pa.new_scores_tables).
  • Ships with a recurring template (one period) and a backfill template (a date range), plus a logSummary() dry run to verify counts before writing.

 

How it is used (short version)
    var calc = new PA_MedianScoreCalculator();
    calc.configure({ indicator: { sysId: '<indicator_sys_id>' }, breakdowns: {...} });
    calc.collect(encodedQuery, scoreField, sourceTable);
    calc.writeMedians(periodStart); // periodStart is a GlideDate​



Prerequisites (full notes in the repo)
  • The indicator, breakdown, and breakdown element records must exist, and each breakdown must be associated with its indicators.
  • The code only uses the indicator, breakdown, and element sys_ids. Breakdown mappings are JavaScript functions per source table, not PA mapping records, and matrix exclusions use breakdown keys you define. So nothing extra to wire up there.
  • The indicator's frequency must match the run cadence (daily indicator for daily runs, monthly for monthly).
Code and full instructions on GitHub:

https://github.com/AbdullahAsad2002/pa-median-score-calculator

 

I would value feedback, especially from anyone running the new scores tables on a different release or with unusual breakdown setups. If you try it, let me know how it goes or open an issue on the repo.

 

Thanks,
Muhammad Abdullah
0 REPLIES 0