01. How it works
Read this once and the screen, the tags and the tutorial will make sense. It takes about 15 minutes.
1. The problem
You have rows of data: invoices, orders, attendance, payments. You want a document for each customer (or class, or project) that shows things like:
- "Your total this half-year: $3,583.34"
- a month-by-month list with a running total
- a table of category by quarter, with a Total row and column
- a bar chart of the months
- a month you can click to jump to that month's detail
Word is good at the page. A database is good at adding things up. DataPublisher joins them. It does the adding up first (we call this the prep stage), then pours the results into your Word template.
2. The pipeline
YOUR DATA RECIPE (prep stage) YOUR WORD TEMPLATE OUTPUT
───────── ─────────────────── ────────────────── ──────
CSV tables ──► group, total, average, ──► <<CustomerTotal>> ──► one finished
or a Data Set running total, top-N, {{ForEach:ByMonth}} document per
cross-tab, chart, <<ByCategory>> customer: Word,
formulas, filters [[Chart_Monthly]] PDF or e-mail
The prep stage hands its results to the merge step in forms you already know from mail merge:
| The recipe produces | It reaches the template as | So you write |
|---|---|---|
| A summary table (rows) | A list you can repeat | {{ForEach:ByMonth}} ... {{EndForEach}} |
| A single total | A field | <<GrandTotal>> |
| A cross-tab | Text that becomes a table | <<ByCategory>>{{CreateReportTable:\|}} |
| A chart | A picture | [[Chart_Monthly]] |
| A barcode | A picture | [[Barcode_Scan]] |
| A label sheet | A list of rows with numbered fields | {{ForEach:Signs}} around one Word table row, with <<Address_1>>, <<Address_2>> ... in its cells |
That is why you rarely learn anything new in Word. You use the same kinds of tags you would use in a normal mail merge.
3. The four things you work with
3.1 Data
Your data is one or more tables. A table is a CSV file: a header row of column names, then one row per item.
In the tutorial:
| Table | One row per | Key columns |
|---|---|---|
customers |
customer (5 rows) | Customer, Email, Region, Segment |
transactions |
invoice (39 rows) | Customer, InvoiceNo, Date, Category, Amount |
The Customer column in transactions says which customer each invoice belongs to. That relationship is a link. With the link
in place, each customer "carries" its own invoices, and your template can repeat them.
Where tables live. A report reads all its tables from one place:
| Place | When to use it |
|---|---|
| A Data Set (recommended) | Any report with more than one table, plus scheduled, e-mailed and server runs. A Data Set holds the tables and their links as one named thing |
| Loose data files | A report on a single file. These are hidden on the screen until you tick Show my loose data files |
A Data Set and loose files are never mixed in one report. If a recipe needs payments.csv next to a Data Set's customers
table, add payments.csv to the Data Set.
3.2 The template
An ordinary Word document with a few tags in it. The template says where things go and how they look. It never says how to calculate them.
| Tag | Meaning |
|---|---|
<<Customer>> |
Replace with this record's Customer |
<<Amount>>{{FormatCurrency}} |
Replace with the Amount, shown as money. A function after a field changes how it is written |
{{ForEach:ByMonth}} ... {{EndForEach}} |
Repeat what is between these tags, once for each row of ByMonth |
<<ByCategory>>{{CreateReportTable:\|}} |
Turn the text in ByCategory into a finished-looking table |
[[Chart_Monthly]]{{ResizeImageTo:420}} |
Insert a picture. 420 is the width in points |
<<Month>>{{LinkTo:Mon:Customer}} |
Make the value a clickable link |
<<Month>>{{Bookmark:Mon:Customer}} |
Mark the place that link jumps to |
3.3 The recipe
A small text file (JSON). You almost never write it by hand. The Summaries & Charts screen builds it from your clicks and shows it on the Recipe file tab. Here is a shortened one:
{
"schemaVersion": 1,
"name": "Customer statement",
"recordKey": "Customer",
"tables": {
"ByMonth": {
"from": "transactions",
"groupBy": ["Customer", { "month": "Date", "as": "Month" }],
"measures": { "Total": { "sum": "Amount" } },
"running": [{ "of": "Total", "as": "Running" }]
}
},
"totals": {
"GrandTotal": { "from": "transactions", "sum": "Amount" }
}
}
It reads like a sentence: "Total of Amount, grouped by Customer and by month of Date, with a running total."
Three things to know:
- No lock-in. It is a plain text file. Anyone can read, copy and edit it.
- Strict, but helpful. A typo is an error with a suggestion ("No column named
Amoutintransactions. Did you meanAmount?"). It never gives a silently wrong answer. - Same everywhere. The same recipe gives the same numbers and the same charts on the server, the command line and the desktop app.
3.4 The output
One finished document per record, as Word (.docx) or PDF. You can also put all records in one combined document, or e-mail
each customer their own file.
4. What is a "record"?
A record is one document's worth of data. The recipe's recordKey decides what it is.
- With
"recordKey": "Customer", you get one record per distinct customer, in the order they first appear in the data. Each record gets its own tables, totals and charts. - Without a
recordKey, each data row is a record, and per-record tables are not attached.
Per record, or the same for everyone? Almost everything can work either way. This is the point newcomers most often trip on.
| Thing | Per record | The same for everyone |
|---|---|---|
| A total | "perRecord": true. Each customer sees their own <<CustomerTotal>> |
The default. <<GrandTotal>> is identical in every document |
| A chart | "scope": "perRecord" (the default). Each customer's own picture |
"scope": "summary". One picture, the same in every document |
| A cross-tab | Each record's own rows and columns | One cross-tab shown in every document |
Example from the tutorial: every statement shows Your total (that customer: Acme Co $3,583.34) next to All customers ($10,713.13, the same on every statement).
5. Where recipes run
| Where | What it does | Notes |
|---|---|---|
| Summaries & Charts screen (in Word: Data > Builder) | Builds a recipe and shows live numbers, tables and charts | The preview uses the first 50,000 rows of a table. A real run always uses every row |
| Run tab (same screen) | Sends the recipe to the DataPublisher server, which makes your documents. Download them or open them in Word | Up to 5,000 records per run. Word or PDF |
| Schedule tab (same screen) | Saves a report and runs it later or on a schedule. Can e-mail each customer their file | Up to 20,000 records and 60 minutes per run. Files are kept for 30 days |
Command line (dp-node) |
Runs a recipe on your own computer. Good for scripts | Needs Node and a license |
| Linux desktop app | Runs recipes on that computer from the same screen | |
| The add-in's Actions > Merge | Ordinary merges, links and report tables | Does not run recipes. Chart and cross-tab fields from a recipe stay empty here |
You may also see two merge modes in the add-in:
- Turbo (the default) merges on your computer in the background and opens the result as a new document. The progress line says
Turbo: merging record 3 of 5. - Interactive has Word merge record by record in the open document. It is the fallback for PDF output. Links inside a loop are only made by Turbo; Interactive shows plain text and tells you so. Interactive does not give each record its own header and footer. The Run tab and the command line do (lesson 17 of 03 Next steps).
6. Preview versus the real run
The preview is for checking your thinking. It shows the tables, totals and charts for one chosen record as you build. It is not the final document.
A good habit: build in the preview until the numbers match what you expect, check them against a source you trust, then run. The tutorial gives you the correct numbers at each step, so you learn what "right" looks like.
7. Vocabulary
| Term | Meaning |
|---|---|
| Add-in | DataPublisher for Word, the task pane inside Word |
| Barcode | A QR or Code 128 picture of a record's value, inserted with [[Barcode_Name]] |
| Chart | A picture made from a summary table, inserted with [[Chart_Name]] |
| Cross-tab | A grid with one row per value of one column, one column per value of another, and a measure in the cells (for example category by quarter) |
| Data Set | A named group of tables and their links. It keeps its own copy of each file |
| Filter | A rule that keeps only some rows of a table, usually using a parameter |
| Grouped layout | Group header, lines, group footer, nested, like a Crystal Reports grouped report |
| Label sheet | Name tags, address labels or signs laid out across a page, from the rows of a table |
| Link (tables) | The relationship that attaches a customer's invoices to the customer |
| Link (document) | A clickable jump inside the finished document, made with {{LinkTo}} and {{Bookmark}} |
| Main table | The table whose rows (or distinct key values) become the records |
| Measure | A calculation inside a summary: sum, avg, min, max, count, median, percentile and others |
| Parameter | A value asked for before a run ("From date", "Region") that filters data and can be printed in the document |
| Prep stage | The step between "data loaded" and "template merged" where the recipe runs |
| Record | One document's worth of data, usually one customer |
recordKey |
The column that defines records (for example Customer) |
| Recipe | The small file that says what to total, group and chart |
| Report table | {{CreateReportTable}}: text turned into a finished-looking table |
| Running total | A cumulative total that restarts for each record (or by another grouping) |
| Sub-report | A second data file linked to the first by customer, summarised on its own |
| Template | Your Word document with tags in it |
8. What this is not
- Not a dashboard. There are no filters a viewer can toggle, no live drill-down and no auto-refresh.
- Not free-form SQL. A recipe summarizes the tables it is given. To get data from a database, use a connector that delivers tables.
- Not editable Word charts. Charts are pictures. That is the trade for working everywhere: Word, PDF, e-mail bodies and
.odt.
Next: 02 Your first report