View as Markdown

Engine

Totals and values placement

Pivot grand totals and subtotals with their positions, values on rows or columns at any level, empty members and the value header.

Grand totals and subtotals

totals: { grand: 'both', grandPosition: 'end', sub: true, subPosition: 'auto' }
  • grand controls the grand totals: 'both', 'rows' (the grand total row only), 'columns' (the grand total column only) or 'none'. grandPosition puts them at the 'start' or the 'end'.
  • sub turns subtotals on or off. Set it to true or false, or pass a record per field ({ year: false }). The showSubTotals flag on a field placed on an axis overrides both.
  • subPosition places subtotals. With 'auto', the compact row header of an expanded member carries its subtotal and column subtotals follow their children. With 'start', subtotals come before the children on both axes. With 'end', they come after: rows get a separate Asia Total row (key '["Asia"]|total') and the member row holds no values.

An axis with no fields still shows one grand total position.

From code, pivot.setTotals({ grand: 'rows', sub: false }) merges into totals (action totals); the totals, subtotals and grandTotals toolbar items do the same from the UI (Toolbar), and showSubTotals: false on a placed field (rows: [{ field: 'region', showSubTotals: false }]) hides that field's subtotals only.

Values placement

valuesPlacement: { axis, index } puts the measures on the 'columns' (the default) or 'rows' axis, at level index among that axis's fields (-1 means innermost). With { axis: 'columns', index: 0 }, the measures are the outer column headers and the column fields repeat under each one. On the rows axis, every member row gets one child row per measure. With a single value field the value level is hidden unless showValueHeader is true.

Empty members

By default an axis shows only member tuples that have rows. showEmptyMembers: true shows every member of a field under each parent, with empty cells. Members removed by a filter stay hidden. The text shown in empty cells (emptyCellText) is a PivotTable prop.

Totals, values placement and empty members

Open demo

Grand totals and subtotals with their positions, measures on rows or columns at any level, the value header, empty members and the empty cell text, all from pivotModel.

Region / Country
2024
2025
2026
Grand total
Amount
Units
Amount
Units
Amount
Units
Amount
Units
Americas
$2,778
49
$4,590
67
$1,507
16
$8,875
132
Brazil
$1,783
39
$2,039
42
-
-
$3,822
81
Canada
$995
10
$2,551
25
$1,507
16
$5,053
51
Asia
$1,567
30
$2,858
60
$4,670
78
$9,095
168
India
-
-
$1,035
27
$2,591
42
$3,626
69
Japan
$1,567
30
$1,823
33
$2,079
36
$5,469
99
Europe
$2,562
40
$4,374
35
$3,586
52
$10,522
127
France
$1,547
10
$1,803
13
$2,059
16
$5,409
39
Germany
$1,015
30
$2,571
22
$1,527
36
$5,113
88
Grand total
$6,907
119
$11,822
162
$9,763
146
$28,492
427