# Totals
URL: https://pro.rv-grid.com/guides/pivot/concepts/totals/
Source: src/content/docs/guides/pivot/concepts/totals.mdx
Description: Learn how Pivot grand totals and subtotals work across rows and generated columns.
Totals help users move from detailed branch-level summaries to whole-table summaries. RevoGrid Pivot supports grand totals and subtotals through `pivot.totals`.

## The Totals Config

```ts
totals: {
  grandTotal: true,
  subtotals: true,
  grandTotalLabel: 'All Sales',
  subtotalLabel: 'Subtotal',
}
```

## What Each Option Does

- `grandTotal`: Adds a grand-total row. When column dimensions exist, it also adds grand-total value columns.
- `subtotals`: Adds subtotal rows for intermediate row branches and subtotal value columns for intermediate column branches.
- `grandTotalLabel`: Overrides the default `"Grand Total"` label.
- `subtotalLabel`: Overrides the default `"Subtotal"` label.
- `suppressSingleChildSubtotals`: Hides subtotal rows for single-source branches where the subtotal duplicates the only leaf.
- `suppressGrandTotalWhenSingleLeaf`: Hides the grand-total row when the whole result is one source-backed leaf.

## Smart Suppression

Use suppression when totals are enabled for broad reports, but small filtered results should avoid duplicate summary rows:

```ts
totals: {
  subtotals: true,
  grandTotal: true,
  suppressSingleChildSubtotals: true,
  suppressGrandTotalWhenSingleLeaf: true,
}
```

Suppression is conservative. Multiple source rows, multiple meaningful leaves, or disabled `subtotals` / `grandTotal` keep the existing total behavior.

## Row Totals

When row fields exist:

- subtotal rows are inserted after the descendants of each branch
- the grand-total row is rendered separately and pinned at the bottom

This keeps the detailed body rows readable while still making the full-table total visible.

## Column Totals

When column fields exist:

- intermediate column paths can expose subtotal value columns
- the full column hierarchy can expose grand-total value columns

Pivot does not create a separate total table. Totals become part of the generated analytical structure.

## Example

For:

```ts
rows: ['region', 'rep'],
columns: ['year', 'quarter'],
values: [{ prop: 'sales', aggregator: 'sum' }],
totals: { grandTotal: true, subtotals: true },
```

You get:

- leaf rows for each `region -> rep`
- subtotal rows for each `region`
- grand total at the bottom
- leaf value columns for each `year -> quarter`
- subtotal value columns for each `year`
- grand-total value columns across all years and quarters

## Important Notes

- Subtotals only appear when a hierarchy has more than one level to summarize.
- Grand totals use the configured label only for display. The internal total keys stay synthetic.
- In remote/server mode, totals stay part of the analytical contract and should be computed by the engine, not recomputed from visible UI cells.

## Common Mistakes

- Expecting `subtotals: true` to add subtotal rows when there is only one row field.
- Expecting grand totals to stay inside the body rows. In the current implementation, grand total rows are pinned bottom rows.
- Confusing column subtotals with collapsed-column placeholders. Those are different features.

## Next

Continue with [Values On Rows](/guides/pivot/values-on-rows/) or [Drill-Down](/guides/pivot/drilldown/).
