Aggregate Functions

Summarize grouped rows with sum, average, count, min, max, or a custom function.

Sum

Set aggregation: { type: "sum" } on a column. Aggregations run on grouped rows — you need row grouping.

TypeScript
{
accessor: "budget",
label: "Budget",
type: "number",
aggregation: { type: "sum" },
}

Average

Arithmetic mean of values in each group.

TypeScript
{
accessor: "rating",
label: "Rating",
type: "number",
aggregation: { type: "average" },
}

Count

Counts non-null values in each group.

TypeScript
{
accessor: "projects",
label: "Projects",
aggregation: { type: "count" },
}

Min / max

Finds the minimum or maximum value in each group.

TypeScript
{
accessor: "score",
label: "Score",
type: "number",
aggregation: { type: "max" },
}

Parse and format values

Use parseValue when source data is formatted (e.g. currency strings), and formatResult to display the aggregate.

TypeScript
{
accessor: "budget",
label: "Budget",
aggregation: {
type: "sum",
parseValue: (val) => parseFloat(String(val).replace(/[^0-9.-]/g, "")),
formatResult: (val) => "$" + val.toLocaleString(),
},
}

Custom aggregation

Set type: "custom" and provide customFn — it receives all values in the group.

TypeScript
{
accessor: "performance",
label: "Performance",
aggregation: {
type: "custom",
customFn: (values) => {
const nums = values.map((v) => Number(v)).filter((n) => !Number.isNaN(n));
if (nums.length === 0) return 0;
return Math.round((nums.reduce((a, b) => a + b, 0) / nums.length) * 10) / 10;
},
},
}

Example

Props

Aggregation Configuration

PropertyRequiredDescriptionExample
ColumnDef.aggregation
Optional
Aggregates child values into parent group rows. Requires rowGrouping. Built-ins: sum, average, count, min, max, or custom.

AggregationConfig

PropertyRequiredDescriptionExample
Required
The aggregation function to use
parseValue
(value: any) => number
Optional
Function to parse string values to numbers (e.g., '$15.0M' to 15000000)
formatResult
(value: number) => string
Optional
Function to format the aggregated result back to string
customFn
(values: any[]) => any
Optional
Custom aggregation function (only when type is 'custom')