Skip to main content

Creating a Subtotal Rule

A Subtotal Rule says which axis to insert lines along and which dimensions to break on.

Adding a rule​

  1. Open the Matrix editor and go to the Spaces tab
  2. Select a Dataset space
  3. In the space's settings, open Subtotals
  4. Click Add Subtotal Rule
  5. Choose an Axis and one or more dimensions to Break on

Axis​

  • Rows — inserts rows, breaking on the dimensions on the dataset's rows.
  • Columns — inserts columns, breaking on the dimensions on the dataset's columns.

To subtotal both rows and columns, add one rule for each axis.

Break on​

Break on lists the dimensions on the chosen axis of the dataset's query, from outermost to innermost. Select one or more of them.

Wherever a selected dimension's member changes, a line is inserted after the group ends. The last group on the axis also gets its line, so every group is followed by a total.

A worked example​

A dataset has Year, Region and Product on its rows, and Sales on its columns. With a Rows rule that breaks on Region:

YearRegionProductSales
2025NorthWidgets100
2025NorthGadgets50
2025North150
2025SouthWidgets80
2025SouthGadgets20
2025South100

Each total line is captioned with the members its group shares, here a Year and a Region. The Product column is left empty, because the line totals every product in the group.

Breaking on more than one dimension​

Select more than one dimension to nest the totals. Adding Year to the rule above gives a line after each region, plus one after each year:

YearRegionProductSales
2025NorthWidgets100
2025NorthGadgets50
2025North150
2025SouthWidgets80
2025SouthGadgets20
2025South100
2025250

Where two groups end at the same place, as South and 2025 do here, the inner line comes first and the outer one follows it.

The dimensions don't need to be next to each other. Breaking on Year and Product, while skipping Region, is valid too.

caution

Breaking on the innermost dimension inserts a line after every single row or column, since the innermost member changes every time. Choose an outer dimension if you want lines after groups.

More than one rule​

A space can have several Subtotal Rules, and they combine. Two rules on the same axis, one breaking on Year and one on Region, give the same result as one rule breaking on both.

Rules on different axes are independent: a Rows rule and a Columns rule on the same space give you both total rows and total columns.

note

If two rules on the same space break on the same dimension, each inserts its own line, so every group gets two identical totals. This is only useful when the rules use different Block Formats.

Messages in the editor​

MessageMeaning
This space has no query configured, so there are no dimensions to break on.Give the space a query first.
The selected axis has no dimensions.The query has nothing on that axis. Add a dimension to it, or choose the other axis.
No dimensions selected — this rule inserts nothing.The rule is saved but has no effect until you pick at least one dimension.
tip

If the query changes later and a rule's dimension is no longer there, that rule quietly inserts nothing. It won't stop the Matrix from loading. Open the rule and choose again.