LyteNyte Grid logo for light mode. Links back to the documentation home page.
Pivoting

Grand Totals

Summarize all pivot data with a grand total row. Configure the grid to display this summary at either the top or bottom of the viewport.

Grand Total Row

To display the grand totals row for pivots, set the pivotGrandTotals property on the client row data source. The pivotGrandTotals property accepts one of two values:

  • "top": Pins the grand totals row to the top of the viewport.
  • "bottom": Pins the grand totals row to the bottom of the viewport.

The grand totals row is an aggregation row. Aggregation rows summarize data but do not contain any children. In the case of pivots, the grand totals row aggregates all rows in the current view.

The demo below shows a measure summing Profit. Rows are pivoted by Country and Product, columns by Age Group. The grand totals row is positioned at the bottom of the viewport.

Row Grand Totals

Fork code on stack blitzFork code on code sandbox

The code below shows the client data source configuration that enables the grand totals row. To compute the grand totals row aggregations, the grid uses the measures defined in the pivotModel property.

const ds = useClientDataSource<GridSpec>({
data: salesData,
pivotMode: true,
pivotGrandTotals: "bottom",
pivotModel: {
columns: [{ id: "ageGroup" }],
rows: [{ id: "country" }, { id: "productCategory" }],
measures: [
{
dim: { id: "profit", name: "Profit", type: "number", cellRenderer: ProfitCell, width: 140 },
fn: "sum",
},
],
},
rowGroupDefaultExpansion: true,
aggregateFns: { sum: aggSum },
});

Next Steps