Guide
Grouped line items with subtotals
Some documents are not one flat list of lines. An expense statement groups by category, a timesheet by project, a quote by section. Each group has a heading, its own lines and a subtotal, and the table ends with a grand total. This walkthrough builds that with one Table.
The one rule: send the data already grouped
The table does not sort a flat list into groups for you. Each record in your data is a group, and each group holds its own list of lines:
{
"report": { "title": "Expense statement", "period": "September 2026", "person": "Elina Berzina" },
"groups": [
{ "name": "Travel", "lines": [
{ "date": "2026-09-02", "description": "Train Riga to Tallinn", "amount": 24.5 },
{ "date": "2026-09-02", "description": "Taxi to the office", "amount": 12.8 },
{ "date": "2026-09-18", "description": "Train Tallinn to Riga", "amount": 24.5 } ] },
{ "name": "Meals", "lines": [
{ "date": "2026-09-02", "description": "Lunch with client", "amount": 38.2 },
{ "date": "2026-09-03", "description": "Team breakfast", "amount": 16 } ] },
{ "name": "Office supplies", "lines": [] }
]
}
Paste it into Manage data (the JSON tab) so the editor has something to show. If your own system sends one flat list with a "category" on each line, group it in your system before it reaches Ristmark — a flat list cannot be turned into groups inside the table.
Step 1 — A table with five rows
- Add a Table and choose its size with Choose table size (the small arrow next to Table in the palette): 3 columns by 5 rows, with the Header row switched on.
- Type the five rows: a header ("Date", "Description", "Amount"), a group heading row, a line row, a subtotal row and a total row. The wording of the group heading, subtotal and total rows will be replaced in a moment by fields.
Step 2 — Make the group repeat
- Select the table and open Repeating rows in the side panel.
- Pick the rows that make up one record: the heading, the line and the subtotal (rows 2 to 4). Everything in one group's design is in those three rows.
- Say how many rows print after the list: 1, the grand-total row.
- Choose the list:
groups. Say what each record is called:group. - Press the button. A plain table has to be turned into a designed grid first (cells that can hold more than text), and the panel tells you what will read differently before you press it. One undo puts everything back.
Step 3 — Merge the wide cells
A group heading should span all three columns, and the subtotal and total labels two. Drag across the cells and use Merge cells in the table's bar. A merged cell may not reach into or out of the repeating rows, which is fine here: each merge stays inside one row.
Step 4 — Say which rows are the lines
- In the side panel, under Groups, pick the rows that make up one line: row 3, the one between the heading and the subtotal. At least one row of a group has to stay outside the lines, as its heading or its subtotal.
- Choose the list inside each group that holds its lines — "group › lines". The panel tells you what your sample holds: "the 3 groups hold 3, 2 and 0 lines".
- Say what each line is called:
line. It has to differ from the group's name. - Press Group these rows.
Step 5 — Fill the cells
The same section now maps each cell to a field. The heading cell reads the group's name; the
line cells read the line's date, description and amount (the amount cell as a currency).
For the totals, you do not type a formula:
- Insert subtotal writes
{{ format(sum($data.group.lines, 'amount'), 'currency') }}into the cell you choose in the subtotal row. It adds up this group's lines. - Insert grand total writes
{{ format(sum(flatten($data.groups, 'lines'), 'amount'), 'currency') }}into the total row.flattenjoins every group's lines into one list, so it adds up every line of the table. - Set the text a group with no lines prints to something like "No expenses this month".
Each is one undo, and the panel names what the cell holds before you press the button.
What you should see
A statement with a heading Travel over three lines and a subtotal of €61.80; Meals over two lines and €54.20; Office supplies with the text "No expenses this month" and a subtotal of €0.00; and a final Total of €116.00. The header row at the top ("Date", "Description", "Amount") is the table's header.
How it breaks across pages
- Each group prints its heading once, then its lines, then its subtotal. The table header repeats at the top of each page.
- A long group continues on the next page; its heading is not repeated there, the lines simply carry on under the table header.
- A heading is never left alone at the foot of a page: it moves with its group's first line. A subtotal never opens a page on its own: it travels with the group's last line. The grand total travels with the last group.
- There are no per-page totals and no "carried forward" figures. Totals are per group or for the whole table.
Variations
- A different second level. Groups nest one level only: a line cannot hold groups of its own. For three levels (department › team › person), flatten one level in your data.
- Ungrouped statement. Stop grouping keeps the records repeating and takes the group structure away; the panel says how many cells that affects before you press it.
Output differences
PDF and HTML print the groups as designed. A Word file gets ordinary table rows, with the header rows marked as repeating; it is a finished document, not a live Word template.
If something looks wrong
- Every group is empty. The list inside each group has the wrong name or the data sends it as something other than a list; the list inside each group shows what your sample holds.
- The grand total is zero or too small. Check that the amount field is a number (not text with a currency sign) in every line.
- A subtotal shows the whole table's sum. It was inserted with the grand-total formula. Select the cell and use Insert subtotal instead.
- A table with thousands of lines stops. At most 3000 lines and 3000 groups print; beyond that the table prints a visible "N line(s) omitted" line instead of dropping them quietly.
- The Merge button is greyed out. It tells you why: a merge may not cross out of or into the repeating rows, and a cell holding a picture cannot be merged.
See Table for the full table help, and Build an invoice for a table of flat lines.
The statement from this guide is kept as the tested example grouped-line-items-1; it is checked automatically to lay out and produce PDF, Word and HTML without errors.