Skip to content

PivotValueField

Since v0.1.1

Defines a value field in the pivot table — which data field to aggregate and how to compute the aggregation.

Multiple PivotValueField entries on the same field with different aggFunc values create separate columns (e.g. “Revenue (Sum)” and “Revenue (Avg)”).

PropertyTypeDescription
fieldstringThe row data field to aggregate (must exist on the source row objects).
aggFuncAggFuncAggregation function — a built-in name or a custom function.
header?stringCustom column header label. Defaults to "field (aggFunc)" if omitted.
format?(value: number) => stringFormat function for display values. Receives the aggregated number and returns a string. When omitted, the original column’s format is used if available, otherwise raw String(value). Aggregates have no source row, so the column’s format is called with row undefined; if it throws (e.g. it reads the row), the raw number is shown. Set this when the column’s format needs the row.
{ field: 'revenue', aggFunc: 'sum', format: (v) => `$${v.toLocaleString()}` }