Interactive Weighted KPI Lab
Test denominator sensitivity and validation boundaries directly in your browser.
Research / Reporting correctness
A deterministic arithmetic investigation using synthetic populations. No client data, timing benchmark or peer-review claim.
By Datta Sable · Published · Version 1
What happens when an overall completion metric is calculated by averaging team percentages? If teams have different sizes, averaging their percentages gives each team equal weight rather than giving each eligible record equal weight. In executive reporting, this distinction is not a cosmetic rounding nuance: it changes the reported KPI by tens of percentage points and can reverse directional trends between periods.
This investigation isolates the exact arithmetic difference between the unweighted mean of group rates and the denominator-weighted aggregate ratio, demonstrates why both formulas are mathematically valid answers to different questions, and provides production-ready SQL, Power BI DAX, and Python patterns to prevent silent metric drift in enterprise scorecards.
The reference implementation in lib/weighted-kpi.ts uses JavaScript Number arithmetic and validates safe integer counts. Each denominator is strictly positive; completed counts are nonnegative and cannot exceed the denominator. Groups are assumed disjoint and their completion definitions identical.
| Group | Completed | Eligible | Group rate | Share of population |
|---|---|---|---|---|
| Team A | 9 | 10 | 90.00% | 9.09% |
| Team B | 10 | 100 | 10.00% | 90.91% |
overall_weighted_rate = sum(completed) / sum(eligible)
mean_group_rate = sum(completed / eligible) / group_countNotice that the overall weighted rate is algebraically identical to a weighted average of group rates where each group's weight is its share of the total eligible denominator (eligible_i / sum(eligible)). When denominators are equal, both formulas collapse to the same number. When denominators vary, the unweighted mean systematically amplifies smaller groups and suppresses larger ones.
On the two-team fixture, the mean group rate is 50.00%, whereas the overall weighted rate is 17.27% (19 / 110). The 32.73 percentage-point gap occurs because Team B accounts for 90.91% of all eligible records (100 of 110) yet receives only 50.00% of the vote in an unweighted mean.
Equal group sizes make the calculations equal. Equal group rates also make them equal. In general, unequal denominators produce different results; the reporting question determines which metric to use:
In real MIS and operations dashboards, the two-team distortion scales across regional hierarchies. Consider a synthetic five-unit fulfillment network where two small pilot branches handle 35 combined orders at over 93% SLA compliance, while three mature hubs handle 1,165 orders with lower compliance.
| Operating unit | On-time orders | Total orders | Unit SLA % |
|---|---|---|---|
| North Metro Hub | 420 | 500 | 84.00% |
| West Industrial Zone | 310 | 450 | 68.89% |
| Pilot Branch A | 19 | 20 | 95.00% |
| Pilot Branch B | 14 | 15 | 93.33% |
| South Rural Cluster | 95 | 215 | 44.19% |
If a spreadsheet summary or Power BI visual takes the simple average of the five unit percentages, the executive headline reads 77.08%. Yet across all 1,200 orders shipped, only 858 arrived on time—an actual customer-experienced SLA of 71.50%. Two pilot branches representing less than 3% of order volume pulled the reported headline up by 5.58 percentage points.
The most common engineering cause of unweighted KPI drift is storing a pre-computed percentage column (such as completion_pct) in an ETL summary table and then applying AVG(completion_pct) in a BI layer. Once the numerator and denominator are discarded, downstream slice-and-dice filters cannot recover the true weighted ratio. Always persist raw additive counts at the reporting grain and compute ratios at query time.
-- Store raw numerators and denominators in the fact or aggregate table.
-- Compute the weighted ratio at query time with zero-denominator protection.
SELECT
region_name,
SUM(completed_count) AS total_completed,
SUM(eligible_count) AS total_eligible,
CAST(SUM(completed_count) AS DECIMAL(18, 6))
/ NULLIF(SUM(eligible_count), 0) AS weighted_completion_rate,
AVG(
CAST(completed_count AS DECIMAL(18, 6))
/ NULLIF(eligible_count, 0)
) AS unweighted_unit_mean
FROM mart_unit_daily_kpi
GROUP BY region_name;-- Weighted portfolio KPI (default for executive scorecards)
Completion Rate % :=
DIVIDE(
SUM( FactUnitKpi[CompletedCount] ),
SUM( FactUnitKpi[EligibleCount] )
)
-- Unweighted unit mean (only when explicitly requested for equal-unit benchmarking)
Mean Unit Completion % :=
AVERAGEX(
VALUES( DimUnit[UnitKey] ),
[Completion Rate %]
)Notice how Power BI's implicit column aggregation (dragging a pre-calculated percentage column onto a card and setting summarization to “Average”) silently produces the unweighted mean. Defining explicit DIVIDE(SUM(...), SUM(...)) measures in the semantic model guarantees that every slicer, drill-down, and matrix subtotal recomputes the true weighted ratio. See the DAX evaluation context guide and Power BI modeling standards for related patterns.
import pandas as pd
# Group-level rollup preserving additive components
summary = df.groupby("region", as_index=False)[["completed", "eligible"]].sum()
summary["weighted_rate"] = summary["completed"] / summary["eligible"]
# Portfolio totals must sum numerators and denominators independently
portfolio_weighted = df["completed"].sum() / df["eligible"].sum()
portfolio_unweighted = (df["completed"] / df["eligible"]).mean()DIVIDE(SUM(...), SUM(...)) measure will fail if an upstream SQL join duplicates rows. Pair this pattern with the SQL join grain study.This example does not estimate population behavior, causal effects, uncertainty, performance or financial impact. It assumes complete, disjoint counts and has no treatment for missing records or zero denominators. Floating-point arithmetic can introduce rounding error in extreme ratios.
Open the interactive weighted KPI lab and use Reset sample to edit denominators in your browser. In the repository, run node --test tests/mission95.test.mjs. The calculation is in lib/weighted-kpi.ts.
The input tables above are synthetic datasets. No external experimental dataset was used. The automated tests are correctness checks, not independent scientific review.
Test denominator sensitivity and validation boundaries directly in your browser.
See how 1-to-many joins inflate order-level sums in an embedded PostgreSQL engine.
Learn row context, filter context, and safe ratio patterns in Power BI.
Review how synthetic demonstrations and verification boundaries are disclosed.
Sable, Datta (2026). How group size changes an overall completion KPI. Version 1. https://dattasable.com/research/weighted-kpi-aggregation
6 December 2026: initial method, synthetic inputs, worked scorecard, SQL/DAX/Python patterns, and tests. Report a calculation issue or suggest a correction.