Weighted aggregators
A built-in weighted average computes sum(value*weight)/sum(weight) using another column as the weight. Correct roll-ups across levels avoid the common error of averaging averages.
Planned. This page shows the specification from issue #196. The live example, source for every framework and the API reference replace it when the feature ships.
Live example
Holdings grouped by Sector > Issuer. Yield is weighted by MarketValue.
Expected behavior
Weighted and simple averages differ visibly. Changing the weight column recomputes all levels correctly.
Planned API surface
columns[].aggregate: {type: 'weightedAvg', weightField}columns[].aggregate: {type: 'weightedSum', weightField}Acceptance criteria
- The parent weighted avg equals the leaf-level sum(v*w)/sum(w), not the mean of the child results. (pending)
- Rows with a null value or null weight are excluded from both the numerator and the denominator. (pending)
- A total weight of zero yields an empty value, not NaN or Infinity. (pending)
- Negative weights are allowed and documented. (pending)