Skip to main content

How Subtotals Are Calculated

Every subtotal line is filled in for you: its data cells get a SUM formula, and its header cells get a caption.

note

This page describes the default subtotal line, which is what you get when a Subtotal Rule has no Block Format selected. If you do select one, the block can replace the line's content, its style, or both. Anything it leaves alone, such as a blank template or an unchecked Apply content keeps the default behavior described here.

The SUM formula​

Each data cell on a subtotal line gets a SUM formula covering its group. When totals are nested, an outer total sums the subtotals one level inside it, not the data rows underneath them. That way nothing is counted twice, and the formula stays short however many rows each group has.

Here is the nested example from Creating a Subtotal Rule, with Sales in column D and the column headers in row 1:

RowYearRegionProductSalesFormula
22025NorthWidgets100
32025NorthGadgets50
42025North150=SUM(D2:D3)
52025SouthWidgets80
62025SouthGadgets20
72025South100=SUM(D5:D6)
82025250=SUM(D4:D4,D7:D7)

The 2025 total in row 8 sums the two region totals in rows 4 and 7, not the four product rows.

The formula is written into every data column of the dataset, with each column's formula reading its own column.

note

Subtotals always sum. To show something else on a subtotal line, such as an average, use a Block Format. See Limitations.

Captions​

The header cells of a subtotal line are captioned the same way as the header cells of the group it totals, so a Region total reads "2025 · North" by default.

Header cells for dimensions inside the one being totalled are left empty. A Region total covers every product, so it has no single product to name. A Year total covers every region and product, so only its Year header is filled.

If you've customized the header cells on that axis, for example to show a member's name or key rather than its caption, subtotal lines use your customizations too.

tip

The default caption is just the member name, with no "Total" wording. To add a label such as "Total North", use a Block Format.

Styling​

By default, a subtotal line looks like the cells around it. Its data cells take the dataset's Data styling, and its header cells take the matching header styling, including formatting rules set at those levels.

To give subtotal lines a style of their own, such as bold text or a background color, use a Block Format with Apply style checked.

Lines run across the whole Matrix​

A subtotal line cuts through the whole Matrix from start to finish: a subtotal row runs the full width of the Matrix, and a subtotal column runs its full height. Each space the line passes through is responsible only for the part of the line that falls within its own boundary. The space applies its content and style to those cells, and nothing beyond them.

A Subtotal Rule's own dataset fills in its part of the line as described on this page. Where the line passes through another space, such as a second dataset or a Row or Column space, that space's cells on the line are left empty and styled as part of that space.

Because each space only handles its own part of the line, a single subtotal line can be shared between spaces. If two datasets would each insert a line in the same place, for example two datasets stacked one above the other that both break after the same column, they share one line, and each fills in its own part of it. Sharing keeps the Matrix compact, since the alternative is a separate line for every dataset, with blank cells wherever the others don't apply.

Rows and columns together​

When a space subtotals both rows and columns, the cell where a subtotal row crosses a subtotal column is left empty. A row total never sums a column total, or the other way around, so a total is never counted twice.