Skip to content

Pivot Aggregations

The Pivot Table supports summary values calculated based on aggregations. These values provide the core insights for your multidimensional analysis.

Pivot Summary

RevoGrid provides a set of standard aggregators through the commonAggregators object.

import { commonAggregators } from '@revolist/revogrid-enterprise';
const pivotConfig = {
// ...
values: [
{
prop: 'Total Spend',
aggregator: 'sum', // Uses built-in sum
},
{
prop: 'Age',
aggregator: 'avg', // Uses built-in average
}
]
};

Available common aggregators include:

  • sum
  • avg (average)
  • count
  • min
  • max
  • med (median)

You can define your own aggregation logic by providing a function. This is useful for complex business calculations.

const customAggregator = (values: number[]) => {
return values.reduce((acc, val) => acc + (val * 1.1), 0); // Example: Add 10% tax to each value before summing
};
const pivotConfig = {
dimensions: [
{
prop: 'price',
aggregators: {
'totalWithTax': customAggregator
}
}
],
values: [
{
prop: 'price',
aggregator: 'totalWithTax'
}
]
};

Summary values are customizable with different formats and text displays. Since dimensions are based on ColumnRegular, you can use standard column features like cellTemplate or cellProperties to style aggregation results.

dimensions: [
{
prop: 'revenue',
cellProperties: ({ value }) => ({
style: {
color: value < 0 ? 'red' : 'green',
fontWeight: 'bold'
}
}),
aggregators: { sum: commonAggregators.sum }
}
]