02. Your first report
You will build a customer statement from scratch. For each of five garage customers, the finished document shows:
- their total
- a bar chart
- a month-by-month list with running totals
- a category-by-quarter table
- a donut chart
- a company-wide line chart
Time: about 90 minutes. Each lesson ends with a check so you know you are on track.
You need: Word with the DataPublisher add-in signed in, and the sample files. Download sample-files.zip and unzip it. If "record", "recipe" or
"tag" are new words, read 01 How it works first.
When you finish, go to 03 Next steps for highlights, formulas, filters, parameters, group order, more numbers, barcodes and labels, headers, sub-reports and schedules.
Lesson map
| # | Lesson | You learn |
|---|---|---|
| 1 | Get the data in | Data files, Data Sets, linking |
| 2 | Look at the finished thing first | The layout of the screen |
| 3 | Your first summary table | Group by, totals, dates by month |
| 4 | Running totals, sorting, top-N | Cumulative totals, keeping the biggest |
| 5 | Totals | Grand total vs. per-customer total |
| 6 | A cross-tab | Category by quarter, with a Total row and column |
| 7 | Charts | Bar, donut and line; per customer vs. everyone |
| 8 | Put it in a Word template | The tags, the template, clickable links |
| 9 | Run it | Server run and command line |
Lesson 1. Get the data in
Goal: have customers and transactions in DataPublisher, linked, so each customer carries its own invoices.
1a. Upload the files
- In Word, sign in to the DataPublisher add-in.
- Go to Data > Files > Data Files > Import Data File.
- Choose both
customers.csvandtransactions.csvfromsample-files/data/(or drag them in). - Each file shows "Uploaded". Close the window.
1b. Make a Data Set
A Data Set groups the two tables and their link as one named thing. It keeps its own copy of each file, so your uploaded files are never changed.
- Go to Data > Data Sets > New Data Set.
- Name it
Reporting Test. Tick customers.csv and transactions.csv. - Under 2. Name the tables, you see
customersandtransactions, each with a Key column. Set the Key column oftransactionsto InvoiceNo (each invoice is unique). - Under 3. Link the tables, you see one suggestion: customers.Customer goes with transactions.Customer. Press Add.
- Press Create Data Set.
You should see: "Your Data Set is ready", with customers 5 rows, transactions 39 rows, and "Linked customers to transactions".
Why the link matters. Without it, a template cannot repeat each customer's invoice rows, and the loop stays empty. If you press Create without adding the suggested link, the screen warns you.
Checkpoint: press View on each table. customers has 5 rows; transactions has 39 rows.
Lesson 2. Look at the finished thing first
It is easier to build something once you have seen it work. Open the finished recipe, look around, then start fresh.
- Go to Data > Builder > Summaries & Charts > Open. A large window opens.
- Main table: choose
transactions (Reporting Test). - Each record is one: choose Customer.
- Press Open recipe file... and choose
sample-files/recipes/statement.recipe.json.
You should see: a note "Opened statement.recipe.json", a form filled with 4 tables, 3 totals and 3 charts, and a preview of Acme Co's numbers with its Monthly bar chart.
The map of the screen
┌───────────────────────────────────────┬────────────────────────────────────────────┐
│ LEFT: BUILD │ RIGHT: SEE │
│ │ │
│ Header: Open recipe file… Download │ Tabs: Preview │ Use in a document │ │
│ Copy recipe Save [Saved ▾] │ Recipe file │ Run │ Schedule │
│ Recipe name │ │
│ Main table ▾ Each record is one ▾ │ Preview: a Totals box, then each summary │
│ Parameters (if any) │ table, cross-tab and chart for the │
│ [ + Summary table ] [ + Cross-tab ] │ chosen record │
│ [ + Total ] [ + Chart ] [ + … ] │ │
│ cards, one per table/total/chart │ "Show <Customer>" picks whose numbers │
│ │ you are looking at │
└───────────────────────────────────────┴────────────────────────────────────────────┘
Spend two minutes here:
- Click the Recipe file tab. That text is the whole recipe.
- Click Use in a document. It lists the tags to type in Word, each with a Copy button.
- Change Show Customer in the preview. The chart title changes to the next customer's name.
Now start clean: close the window and open it again, choose the same Main table and Customer, and leave the form empty. The preview tells you to add a summary table.
Lesson 3. Your first summary table
Goal: a table called ByMonth with one row per customer per month, showing the total of Amount.
- Press + Summary table. A card appears, "from
transactions". Its default name may beSummary2. (It is notSummarybecause the data already has a column with that name, and a table may not share a name with a column.) - In the first box of the card (the table's name), type
ByMonth. - Under Group by, choose Customer, "as it is".
- Press + Group column. Choose Date, then by month. In the name box that appears, type
Month. - Under Calculate, choose Total of and the column Amount. The "call it" box fills with
TotalAmount. Change it toTotal.
Until step 5, the preview shows a red message saying the table "needs a calculation". That is expected.
You should see, in the card:
Total of Amount for each Customer and Date by month, from transactions.
and in the preview a table ByMonth with the columns Customer, Month and Total. Acme Co has six rows (2026-01 to 2026-06), and the 2026-01 Total is 430.50.
Check the number yourself
Acme's January invoices in transactions.csv are INV-1001 (120.50) and INV-1002 (310.00).
120.50 + 310.00 = 430.50 ✔
Make it look like money
Open More on the card and set Numbers to As money. The column now reads $430.50, $713.35, and so on.
| Numbers | Looks like | Use it for |
|---|---|---|
| plain (default) | 1020.00 |
Numbers other tools will read |
| with thousands separators | 1,020.00 |
Tables |
| as money | $1,020.00, -$5.00 |
Statements |
| percent | 12.5% (from a fraction of 0.125) |
Calculated shares (lesson 12) |
Set As money on ByMonth and keep it.
In recipe words, you just wrote:
groupBy: ["Customer", {month: "Date", as: "Month"}],measures: {Total: {sum: "Amount"}}. Check the Recipe file tab to see it.
Lesson 4. Running totals, sorting and "top N"
4a. Running total
- On the
ByMonthcard, open More and press + Running total. - Choose
Total, and call itRunning. Leave "restart for" on each record (default).
You should see, for Acme: 430.50, 1,143.85, 1,363.85, 1,687.85, 3,398.34, 3,583.34. The total starts again at the first
row of Birch & Sons (99.00).
Now change "restart for" to never (one running total). Birch's first row is no longer 99.00, because the count carries on across customers. Put it back to the default.
4b. Sort
Press + Sort. Choose Customer, then add another sort, Month. The rows reorder. The finished recipe sorts by Customer, then Month.
4c. Top N (try it, then undo it)
Tick Keep only the top 2 by Total.
You should see only the two biggest months per customer, plus a row called Other that holds the rest. Press "leave the rest out" to drop Other, or "roll it into 'Other' instead" to bring it back. Then untick the box. We want all six months.
Top-N is how you keep a donut chart readable. A donut with more than 8 slices shows a warning.
Lesson 5. Totals
A total is a single number. There are two kinds, and the difference matters:
| Same in every document | Different in each document | |
|---|---|---|
| Example | All customers' grand total | This customer's own total |
| Setting | Leave "worked out for each record" unticked | Tick it |
- Press + Total. Name it
GrandTotal, choose Total of Amount. Leave the per-record box unticked. - Press + Total again. Name it
CustomerTotal, Total of Amount. Tick "worked out for each record". - Press + Total a third time. Name it
VisitCount, choose the count option (it counts rows), and tick "worked out for each record".
You should see, in the Totals box at the top of the preview:
| Total | Value |
|---|---|
GrandTotal |
10713.13 |
CustomerTotal (Acme Co) |
3583.34 |
VisitCount (Acme Co) |
12 |
Change Show Customer to Birch & Sons. CustomerTotal becomes 1629.35; GrandTotal does not change.
Leave the totals' Numbers on "plain" for this tutorial. In lesson 8, the template will format them with
{{FormatCurrency}}. Format a number in one place (the recipe or the template) and check the result if you do both.
Lesson 6. A cross-tab: category by quarter
A cross-tab is a grid. Rows are one column's values, columns are another's, and the cells hold a calculation.
- Press + Cross-tab (at the top of the "Summary tables and cross-tabs" box). A purple-edged card appears.
- Name it
ByCategory. - A row for each
Category. A column for eachQuarter. Total ofAmount. - On the same line, tick Add a Total row and column. (You may need to scroll down on the left.)
- Shows: a table inside each record. Numbers: As money.
You should see, for Acme Co (use Show more if needed):
| Category | Q1 | Q2 | Total |
|---|---|---|---|
| Fees | $540.00 | $249.00 | $789.00 |
| Fuel | $195.60 | $410.00 | $605.60 |
| Labor | $98.25 | $309.99 | $408.24 |
| Parts | $530.00 | $1,250.50 | $1,780.50 |
| Total | $1,363.85 | $2,219.49 | $3,583.34 |
Switch to Eastside Tire. You get a smaller grid (Fuel and Tires, then Total). Each customer gets only the categories and quarters they actually have. The columns are discovered when the report runs.
Try this, then undo it: change Total of to Average of on this card. The Add a Total row and column box greys out, because averages cannot be added up. Set it back to Total of.
Lesson 7. Charts
A chart is drawn from a summary table (never from a cross-tab). First you need two more small tables.
7a. Two more summary tables
| Name | Group by | Calculate |
|---|---|---|
MixTable |
Customer (as it is), Category (as it is) | Total of Amount, call it Spent |
CompanyByMonth |
Date by month, name it Period |
Total of Amount called Spent, and the count of rows called Visits |
MixTable means "what each customer spent on each category". CompanyByMonth means "the whole business, month by month".
7b. The bar chart: Monthly
- Press + Chart. Name it
Monthly. Type: Bar chart. From:ByMonth. - Across: Month. Measured: Total.
- Press + Another series and choose Running.
- Title:
Spending by month - {Customer}. Numbers: Money.
You should see a chart titled Spending by month - Acme Co, with two bars per month (blue for Total, orange for Running), values on the bars, a legend and a dollar axis. Under the chart is a caption starting "Bar chart:" with the values. That text is for screen readers, and it is carried into the document as alt text.
Change the record to Birch & Sons. The title changes and there are four months.
7c. The donut: Mix
Press + Chart. Name it Mix. Type: Donut chart. From: MixTable. Across: Category. Measured: Spent. Title:
Where {Customer} spends. Numbers: Money.
7d. The company line: Company
Press + Chart. Name it Company. Type: Line chart. From: CompanyByMonth. Across: Period. Measured: Spent. Title:
All customers. Numbers: Money. Set One chart to for everything.
You should see the same chart whichever record you show. That is a "summary-scope" chart: one picture, the same in every document.
Chart facts worth knowing
| Question | Answer |
|---|---|
| Which chart types are there? | Bar, horizontal bar, line, area, combo, donut, pie, scatter, bullet, sparkline and histogram, plus some specialist types listed in 05 Reference |
| Does a chart need numbers? | Yes. The measured column must be a calculation or running total, not a group column. Otherwise you see "...is a groupBy column, not a number" |
| Where do bars and lines start? | At zero (you can change this deliberately in the reference) |
| Can a donut have several series? | No. Switching a two-series bar chart to a donut drops the second series |
| Colors | A fixed color-blind-safe palette, unless you choose your own |
| Why do they look the same on every machine? | The font is built in, so the same data gives the same picture everywhere |
| Size | Optional width and height in pixels. Pictures are drawn at 2x so print and PDF stay sharp |
Your recipe now has 4 tables, 3 totals and 3 charts, the same as the finished one from lesson 2.
Lesson 8. Put it in a Word template
Everything so far lives in the recipe. The template only says where each piece goes.
8a. Let the screen draft it
- Open the Use in a document tab. You see a list of tags, each with a Copy button. For example:
{{ForEach:ByMonth}} ... {{EndForEach}}: repeats for each of the record's own rows<<ByCategory>>{{CreateReportTable:\|}}: a cross-tab, written as a table (keep it in a paragraph of its own)<<GrandTotal>>[[Chart_Monthly]]- Press Copy everything, open a blank Word document and paste. You get a first draft of the whole template, in the same order as the preview.
8b. A template you write yourself
Type this in a new Word document. Style it any way you like. The tags are what matter.
<<Customer>>
Statement, January to June 2026
Your total: <<CustomerTotal>>{{FormatCurrency}} All customers: <<GrandTotal>>{{FormatCurrency}} Visits: <<VisitCount>>
[[Chart_Monthly]]{{ResizeImageTo:420}}
By month
{{ForEach:ByMonth}}
<<Month>> <<Total>> running <<Running>>
{{EndForEach}}
By category and quarter
<<ByCategory>>{{CreateReportTable:|}}
[[Chart_Mix]]{{ResizeImageTo:300}}
Everyone, month by month
[[Chart_Company]]{{ResizeImageTo:420}}
Save it as my-statement.docx.
Rules that save you an hour:
| Rule | Why |
|---|---|
Put <<ByCategory>>{{CreateReportTable:\|}} in a paragraph of its own |
The whole paragraph is replaced by the table. Any other text in it is lost |
| Put a paragraph between two back-to-back tables | Otherwise the second table sits flush against the first |
{{ResizeImageTo:N}} is in points. Text width on a Letter page is about 468 |
Two charts side by side need about 226 each |
Do not type literal {{...}} or <<...>> in explanatory text |
It is treated as a tag, and you get an "Unknown token" warning. Describe it in words |
| The loop name must match a table name exactly | {{ForEach:ByMonth}} needs a table called ByMonth |
Inside a ForEach, write <<Month>>, not <<ByMonth.Month>> |
You are already inside that table's row |
8c. Make the months clickable (links)
A summary row can jump to its detail, and the detail can jump back. This works in Word and survives PDF export.
- In the month list, write the month as
<<Month>>{{LinkTo:Mon:Customer}}. - On a detail page, write the heading as
Detail for <<Month>>{{Bookmark:Mon:Customer}}. - At the top, mark the customer's name with
<<Customer>>{{Bookmark:Top}}. At the bottom of each detail page, writeBack to the top: <<Customer>>{{LinkTo:Top}}.
The sample template sample-files/templates/T5-statement-recipe.docx does exactly this. Open it to see.
How it works. {{Bookmark:Mon:Customer}} wraps the value in a hidden Word bookmark whose name is built from the group (Mon),
the value (2026-03) and the qualifier field (Customer). {{LinkTo:Mon:Customer}} builds the same name and links to it.
The qualifier (:Customer) matters when one document holds many customers. "2026-03" under Acme and "2026-03" under Birch are
different bookmarks. Without the qualifier, every customer's link would jump to the first customer's page.
| Mistake | Result |
|---|---|
A {{LinkTo}} with no matching {{Bookmark}} |
Plain text, with a warning |
| Two bookmarks with the same name | The first is kept and the rest are dropped, with a warning |
{{Bookmark:Q:NoSuchField}} |
A warning that the field NoSuchField does not exist |
8d. Upload the template
Upload my-statement.docx under Files > Word Files. The Run tab (next lesson) lists templates by the file names you
uploaded.
Do not merge it with Actions > Merge. The add-in's own merge command does not run recipes, so
[[Chart_Monthly]]and<<ByCategory>>would come out empty. Run recipes from the Run tab, the command line, or the Linux app.
Lesson 9. Run it
9a. On the server (the Run tab)
- On the screen, set Main table to
customers (Reporting Test)and Each record is one to Customer. The statement now runs once per customer, andtransactionsis read as its detail. - Open the Run tab. Open the Template list. Your uploaded templates appear by name. Choose
my-statement.docx(or the sampleT5-statement-recipe.docxto compare). - Leave the rest as it is. Press Run.
You should see: a progress bar ("Merging record 2 of 5..."), then "Finished. 5 records in my-statement_date_time.docx", a Download button and, inside Word, Open in Word.
Open the file and check:
| Look for | Acme Co should show |
|---|---|
| Customer total | $3,583.34 |
| All customers | $10,713.13 |
| Visits | 12 |
| Month list | 430.50, 713.35, 220.00, 324.00, 1,710.49, 185.00. The running total ends at 3,583.34 |
| Category table | Total row $1,363.85, $2,219.49, $3,583.34 |
| Pictures | A bar chart, a donut, and a line chart ("All customers", identical on every statement) |
The five customers appear in the order they first appear in the data: Acme Co, Birch & Sons, Dunn's Auto, Cedar Ridge Garage, Eastside Tire.
9b. More to try on the Run tab
| Try | Result |
|---|---|
Type Q3 Statements in Output file name |
The file is called Q3 Statements.docx |
| Layout: "Run them together, no page breaks" | No page break between customers |
| Press Run, then Cancel straight away | "The run was cancelled." (or the finished box, if the run won the race) |
Run a recipe with a mistake (sample-files/recipes/broken.recipe.json) |
A red box lists every problem at once. No document is made |
9c. On the command line (optional)
Use the command line for scripts, for another computer, or to see exactly what the engine does. Run these from the folder that
contains sample-files:
# 1. Look at what the recipe produces, before making any documents
dp-node prep --data sample-files\data\transactions.csv --recipe sample-files\recipes\statement.recipe.json --preview
# 2. Make the documents
dp-node merge --template sample-files\templates\T5-statement-recipe.docx `
--data sample-files\data\transactions.csv `
--recipe sample-files\recipes\statement.recipe.json `
--out out\t5 --name "{Customer}"
You should see: step 1 prints "5 record(s)", then each table with its rows (ByMonth, ByCategory, MixTable,
CompanyByMonth) and the totals, including GrandTotal 10,713.13, with no errors. Step 2 finishes with exit code 0 and writes
five files (Acme Co.docx, Birch & Sons.docx, Cedar Ridge Garage.docx, Dunn's Auto.docx, Eastside Tire.docx) with no
warnings.
To put every customer in one combined file, replace --name "{Customer}" with --mode one-per-page. (--name cannot be used
in that mode.)
| Exit code | Meaning |
|---|---|
| 0 | Done |
| 1 | Usage error |
| 2 | File not found |
| 3 | Invalid recipe, job or parameter. Nothing was written |
| 4 | The run failed (or the server refused or could not be reached) |
| 5 | Finished with warnings. Files are written. Read the warnings |
| 6 | An output file already exists (add --overwrite on job commands) |
Checkpoint: you now have the whole loop: data, recipe, template, documents.
Next: 03 Next steps