Skip to content

Subreports

Each customer shows its orders with a subreport, and the report ends with another one: a summary with a chart. Subreports read the main report’s datasets by name and filter them by the parameters they are given.

Standards: PDF/A-2b · PDF/UA-1, checked with veraPDF on every change. Download the PDF.

Page 1 of the subreports, rendered by Tagua.

The same report as an Excel workbook (download it), from tagua render customers.report.yaml --out customers.xlsx; see Excel export. Each customer’s sparkline is an Excel sparkline in its cell, and the summary a native Excel chart.

ABC
1Customer orders
2Contoso Ltd · Dublin
3OrderDateAmount
4SO-100104/02/2026£157.50
5SO-100710/02/2026£382.50
6SO-101316/02/2026£607.50
7SO-100407/05/2026£270.00
8SO-101013/05/2026£495.00
9Contoso Ltd: 5 orders£1,912.50
10Fabrikam · Cork
11Fabrikam has no orders.
12Northwind Traders · Galway
13OrderDateAmount
14SO-100609/01/2026£345.00
15SO-101215/01/2026£570.00
16SO-100205/03/2026£195.00
17SO-100811/03/2026£420.00
18SO-101417/03/2026£645.00
19SO-100306/04/2026£232.50
20SO-100912/04/2026£457.50
21SO-100508/06/2026£307.50
22SO-101114/06/2026£532.50
23Northwind Traders: 9 orders£3,705.00
24Summary
Customer orders · the first 24 of 26 rows
  • A subreport per row, with parameters
  • A subreport at the end, with a chart
  • Shared datasets filtered by parameters
  • PDF/A-2b and PDF/UA-1, with the subreports’ fonts embedded too
customers.report.yaml
# yaml-language-server: $schema=../schema/template.schema.json
# Subreports: each customer shows its orders with a subreport, and the report ends with a second one, a
# summary with a chart. Each customer's heading has a sparkline of its orders. Subreports read the same data by dataset name and filter it by their parameters.
# PDF/A-2b and PDF/UA-1: the subreports embed their fonts too.
version: 1
title: Customer orders
culture: en-GB
document:
author: Acme Ltd
compliance: [pdf-a-2b, pdf-ua-1]
page:
size: A4
margins: 20mm
fonts:
Inter: { regular: fonts/Inter-Regular.ttf, bold: fonts/Inter-Bold.ttf }
styles:
default: { font: Inter, fontSize: 9.5pt, color: "#1F1F1F" }
customer: { fontSize: 12pt, fontWeight: bold, borderBottom: "0.75pt solid #1F1F1F", padding: 0 0 3pt 0 }
data:
customers:
fields: { Id: int32, Name: string, City: string }
orders:
fields: { CustomerId: int32, Number: string, Date: date, Amount: decimal }
body:
dataset: customers
sort: [Name]
reportHeader:
- padding: 0 0 12pt 0
content:
- { type: text, value: "Customer orders", fontSize: 18pt, fontWeight: bold, tag: h1 }
detail:
- padding: 0 0 14pt 0
content:
# The heading line carries a sparkline of the customer's orders, a column each, beside the name.
- type: stack
direction: row
style: customer
content:
- { type: text, value: "{Name} · {City}", tag: h2, width: 1fr }
- type: chart
width: 80pt
height: 13pt
dataset: orders
filter: =CustomerId == Parent.Id
sort: [Date]
category: "{Number}"
series: [ { value: =Amount } ]
alt: "Sparkline of {Name}'s orders, oldest first."
- type: subreport
template: subreports/orders.report.yaml
parameters: { customer: =Id, customerName: =Name }
reportFooter:
- content:
- { type: subreport, template: subreports/summary.report.yaml }
pageFooter:
- content:
- { type: text, value: "Page {PageNumber} of {TotalPages}", align: right, color: "#6B6B6B", fontSize: 8pt }
subreports/orders.report.yaml
# yaml-language-server: $schema=../../schema/template.schema.json
# One customer's orders: used as a subreport by customers.report.yaml, which passes the customer.
version: 1
title: Orders
culture: en-GB
fonts:
Inter: { regular: fonts/Inter-Regular.ttf, bold: fonts/Inter-Bold.ttf }
styles:
default: { font: Inter, fontSize: 9.5pt, color: "#1F1F1F" }
th: { fontWeight: bold, color: "#6B6B6B", borderBottom: "0.5pt solid #BBBBBB", padding: 4pt 0 2pt 0 }
total: { fontWeight: bold, borderTop: "0.5pt solid #BBBBBB", padding: 2pt 0 0 0 }
parameters:
customer: { type: int32 }
customerName: { type: string }
data:
orders:
fields: { CustomerId: int32, Number: string, Date: date, Amount: decimal }
body:
dataset: orders
filter: =CustomerId == customer
sort: [Date]
reportHeader:
- content:
- type: table
dataset: orders
filter: =CustomerId == customer
sort: [Date]
headerStyle: th
columns:
- { header: Order, value: "{Number}", width: 1fr }
- { header: Date, value: "{Date:d}", width: 90pt }
- { header: Amount, value: "{Amount:C}", width: 90pt, align: right }
footer:
- style: total
cells:
- { value: "{customerName}: {Count(Number)} orders", span: 2 }
- { value: "{Sum(Amount):C}", align: right }
detail: []
noData:
- content:
- { type: text, value: "{customerName} has no orders.", color: "#6B6B6B", italic: true }
subreports/summary.report.yaml
# yaml-language-server: $schema=../../schema/template.schema.json
# A summary of all orders, with a chart: used as a subreport at the end of customers.report.yaml.
version: 1
title: Summary
culture: en-GB
fonts:
Inter: { regular: fonts/Inter-Regular.ttf, bold: fonts/Inter-Bold.ttf }
styles:
default: { font: Inter, fontSize: 9.5pt, color: "#1F1F1F" }
data:
orders:
fields: { CustomerId: int32, Number: string, Date: date, Amount: decimal }
body:
dataset: orders
reportHeader:
- padding: 6pt 0 0 0
content:
- { type: text, value: "Summary", fontSize: 12pt, fontWeight: bold, tag: h2 }
- { type: text, value: "{Count(Number)} orders worth {Sum(Amount):C} in total." }
- type: chart
dataset: orders
sort: [Date]
category: "{Date:MMM}"
series: [ { name: Orders, value: =Amount } ]
format: C0
height: 150pt
alt: Column chart of the value of orders per month.
detail: []

Save the template, put the fonts it names next to it (Inter and the Noto fonts are free, under the SIL Open Font License), and run:

Terminal window
tagua render customers.report.yaml --open

Without a data file, tagua render makes up sample rows from the field types; see Preview as you edit.