03. Next steps

You have built a working report. These nine lessons add the features most real reports need. Each one stands alone, so do them in any order. Lessons 10 to 18 continue the numbering from 02 Your first report.

# Lesson You learn
10 Save, reopen and share a recipe Recipe files
11 When the data is messy Red errors vs. yellow warnings
12 Highlights, formulas and keeping only what matters Conditional formatting, calculated columns, dropping groups, cross-tab rows or records
13 Parameters Asking for values before a run: several values, a date range, "(All)", lists that depend on each other
14 Grouped layouts and sub-reports Crystal-style header/lines/footer, ordering the groups, summary only, a second data file
15 More numbers: median, percentile, rank and previous row Extra summary functions, rank, previous row, ISO weeks
16 Barcodes and label sheets (QR codes, name tags, property signs) A QR or bar code on each record, sheets of labels
17 Headers, footers, IF / ELSE and a page that follows the record Merge fields in headers and footers, two-way blocks
18 Schedule and deliver Scheduled runs, e-mail, API keys, links for other people

Before you start, open the screen as in lesson 2 and use the sample files in sample-files/.


Lesson 10. Save, reopen and share a recipe

A recipe is a file. Treat it like one.

Button What it does
Save Saves it on the server under a name. The Saved list shows all your saved recipes, grouped by Data Set and "Your data files". Picking one switches the Main table to match
Download Gives you a file named from your recipe name, ending .recipe.json
Copy recipe Puts the same text on the clipboard
Open recipe file... Reads a .recipe.json into the form. A file that is not a recipe gives a red notice and keeps what you had

Try the round trip: Download, close the screen, reopen it, then Open recipe file.... Every table, total and chart comes back. Type a Recipe name in the header (for example Customer statement); it appears as "name" in the file.

Reordering

On the Preview tab, each table, chart and total has small ▲ ▼ buttons and a grip. Use them (or drag) to reorder. The order changes the preview, the cards on the left, the recipe file and the "Copy everything" draft. Tables only move among tables, charts among charts, and totals among totals.

Editing the recipe by hand

You can. Open the Recipe file tab, or edit a downloaded file. The rules:

  • Unknown keys are errors, so typos never pass silently.
  • schemaVersion is required and is 1.
  • A table, total or chart name must not equal a data column's name.

Every mistake in a hand-edited file is reported at once, with "Did you mean...?" for column, table and function names. Open sample-files/recipes/broken.recipe.json and press Run to see the style:

recordKey: no column named 'Custmer' in any table. Did you mean 'Customer'?
Table 'ByMonth': no table named 'transaction'. Did you mean 'transactions'?
Table 'Bad', measure 'Total': unknown function 'summ'. Did you mean 'sum'?
Chart 'Oops': 'lines' is not a valid type. Did you mean 'line'?
Chart 'Oops': 'from' must be one of the tables in this recipe.

Lesson 11. When the data is messy, and when you make a mistake

DataPublisher separates two kinds of problem, and the color tells you which.

Color Meaning Does the report still run?
Red "Fix these first" You made a mistake in the recipe No. Nothing is produced until you fix it
Yellow "Worth a look" The data has something odd Yes. Odd values are skipped, and you are told where

11a. Red: make mistakes on purpose

Try each one on the screen. Each gives a plain-words message, never a blank preview or a crash.

Do this You should see
Set a calculation's "call it" name to Amount "...the name 'Amount' is also a column in 'transactions'. Rename the measure so the merge can tell them apart."
Give two tables the name ByMonth A message that the name is already used
Make a chart measure a group column (such as Customer) "...is a groupBy column, not a number. Use a measure or running total: ..."
Clear Each record is one while a per-record chart exists "a perRecord chart needs "recordKey"... or set "scope": "summary"."
Give a cross-tab the same column for rows and columns "'rows' and 'columns' are both ...; they need to be different columns."

Put each one back as you go.

11b. Yellow: messy data

The sample files include sample-files/data-messy/transactions.csv. It holds the same invoices plus five messy rows: a blank amount, n/a as an amount, $1,250.50, a refund of -75.00, and a date that is not a date. It has the same file name on purpose, so it can stand in for the clean one.

  1. Import data-messy/transactions.csv into a separate Data Set called Reporting Messy.
  2. Open the screen on it, set Each record is one to Customer, and rebuild ByMonth (or open statement.recipe.json).

You should see a yellow Worth a look box:

  • 1 blank value in 'Amount' (first: row 40)
  • 2 values that are not numbers (first: row 41, 'n/a')
  • 1 value in 'Date' that is not a date (first: row 44)

The preview still works. Acme's total stays 3,583.34. Birch & Sons, May is 45.50: the refund is included (120.50 minus 75.00).

Watch out for dollar signs. An amount written with a dollar sign ($1,250.50) is not read as a number. It is skipped with a warning. Real exports often have a $, so clean the column before you summarize it, or watch for the "not numbers" warning.

On the command line, messy data finishes with exit code 5 and warnings that name the table and the first bad row.


Lesson 12. Highlights, formulas and keeping only what matters

12a. Highlight values (conditional formatting)

Show a value in a color, in bold or highlighted when it passes a test. You do no work in Word.

  1. Open sample-files/recipes/statement.recipe.json, then the ByMonth card, then More, then Highlight values.
  2. Press + Highlight rule. Column: Total. is more than 1000. Highlight: yellow.
  3. The preview colors every Total over 1,000 yellow at once.
  4. Add a second rule: Total is less than 0, color red, bold. The first rule that fits a value is used, so the order matters.
  5. On a total (for example GrandTotal), add a rule: is more than 1000, green, bold.

The available tests are: less than, less than or equal, more than, more than or equal, equals, not equal, between (two boxes), is, contains, is empty and is not empty. A rule needs at least one of a color, bold, italic or highlight.

Run it from the Run tab with a template that uses <<Total>> inside a loop (the sample T5 does). The same cells are colored in the Word document. The numbers themselves are unchanged. Cross-tabs and chart pictures are not styled by rules.

12b. Formulas: calculated columns and formula totals

Open sample-files/recipes/formulas.recipe.json (Main table = customers, Each record = Customer).

Calculated columns on the ByCategory summary table:

Name Formula Shown as
ShareOfCustomer Total / CustomerTotal percent
ShareOfCompany Total / GrandTotal percent

You should see, for Acme Co: Fees $789.00, 22.0% / 7.4%. Fuel $605.60, 16.9% / 5.7%. Labor $408.24, 11.4% / 3.8%. Parts $1,780.50, 49.7% / 16.6%.

Formula totals, in the Totals box for Acme: AvgPerVisit = $298.61 (3,583.34 / 12) and CompanyShare = 33.4%, highlighted yellow and bold because its rule says "more than 30". Pick Eastside Tire: 8.0%, not highlighted.

Add your own: press + Formula in the Totals area. Name it Half, use the formula GrandTotal / 2, and set Numbers to As money. It appears as about $5,356.57.

The formula language is small and safe. Nothing is run as code.

You can use Examples
Numbers, names, + - * /, parentheses (Revenue - Cost) / Revenue
Comparisons < <= > >= == != GrandTotal > 10000
round(x, 2), abs(x), min(a, b, ...), max(a, b, ...), if(condition, then, otherwise) if(GrandTotal > 10000, 1, 0)

Try some errors on purpose:

You type You should see
GrandTotl / 2 "no total named 'GrandTotl'. Did you mean 'GrandTotal'?"
1 + What is wrong and where
sqrt(4) "there is no function 'sqrt'. The functions are: round, abs, min, max, if"
CustomerTotal / (VisitCount - VisitCount) The values are empty and a yellow note says "5 value(s) of 'AvgPerVisit' could not be calculated". The rest of the report still works

A calculated column can also be charted. Add a donut from ByCategory with x = Category, y = ShareOfCustomer, and numbers set to Percent.

12c. Show only what matters: drop groups, or drop whole records

A highlight colors a group. These two options remove it.

Keep only groups where drops a group because of its own total, the way SQL's HAVING does.

  1. Open statement.recipe.json, then the ByMonth card, then More, then Keep only groups where.
  2. Press + Condition. Column: Total. is more than 1000.
  3. The preview table shrinks to 2 rows: Acme Co 2026-05 $1,710.49 and Cedar Ridge Garage 2026-03 $1,660.50.
  4. Change it to is between 500 and 1000. Five groups appear, including Dunn's Auto 2026-02 ($948.25).
  5. Look at the Totals box. GrandTotal is still 10,713.13. A note under the table says how many groups were left out and what they add up to. Totals always include every group, so a filtered table adds up to less than GrandTotal.
  6. Add a running total. It runs over the remaining rows only. The filter is applied first, then top-N, sorting, running totals and calculated columns.

You can add several conditions, and every condition must hold. You can test a table's calculations, but not a running total or a calculated column (the screen tells you). A grouped layout has the same box and tests subtotals or the count. Each condition has a level choice: level 1, the outermost groups, is the usual one, and lesson 14 shows level 2. If you remove everything (for example "more than 1000000"), you get an empty table and a plain note, not an error.

A cross-tab has its own version. Open sample-files/recipes/parity-statement.recipe.json (Main table = customers, Each record = Customer) and look at the Mix card (rows Customer, columns Category, with a Total row and column). Open More: keep only some rows or columns, press + Condition, and set The Total of each row is more than 1600.

You should see three rows: Acme Co, Birch & Sons and Cedar Ridge Garage, and a Total row of 8,352.33 (Fees 974.00, Fuel 1,600.10, Parts 2,621.25, Tires 1,120.24, Labor 2,036.74). Dunn's Auto (1,503.35) and Eastside Tire (857.45) are gone, and a yellow note says 2 of 5 records have no rows. With Total on, the Total row adds up what is shown. Choose column instead of row to drop whole columns by their Total. In the recipe the condition sits inside pivot, next to value:

"pivot": { "rows": "Customer", "columns": "Category", "value": { "sum": "Amount" }, "totals": true,
           "having": [ { "column": "Total", "when": "gt", "value": 1600 } ] }

The column is always Total (a row's or column's total), and "on": "columns" judges columns instead of rows.

Skip records where drops a whole record, so no document is made for it. For example, "skip customers whose balance is zero".

  1. In the Your data card, with Each record set to Customer, find Skip records where.
  2. Press + Condition. Choose the total CustomerTotal, is at least, 2000. (It must be a per-record total.)
  3. The Show list now holds only Acme Co and Cedar Ridge Garage, and a note says 3 records are skipped.
  4. Run it on the Run tab. You get two documents, not five. GrandTotal is unchanged.

Skipping is not a warning, so a command-line run still exits with 0. If every record is skipped, the run stops and says so.


Lesson 13. Parameters: ask for values before a run

13a. One value at a time

A parameter is a value you are asked for before the run. A filter uses that value to keep only some rows. If you know Crystal Reports, this is a parameter field plus a record selection formula.

Open sample-files/recipes/parameters.recipe.json (Main table = customers, Each record = Customer).

You should see a Parameters card with four parameters:

Name Asked as Type
From From date date
To To date date
Area Region (offers the distinct values of customers.Region) text
MinAmount Smallest invoice (default 0) number

and four filters, such as "Keep rows of transactions where Date is on or after From". At the top of the Preview tab, a Try values for the preview card asks the same questions. Region is a drop-down listing (any), East and West.

Try it in the preview:

Do this You should see
From date 2026-02-01 GrandTotal drops to invoices on or after 1 February
Region = East Only East customers remain as records, and the totals follow
Smallest invoice 100 Invoices under $100 stop counting
From date yesterday "Parameter 'From': 'yesterday' is not a date, such as 2026-01-31."

Print the values in the document. Every parameter is also a field: <<From>>, <<To>>, <<Area>>, <<MinAmount>>. The sample template T9-parameters.docx starts with Period: <<From>> to <<To>> Region: <<Area>> Smallest invoice: <<MinAmount>>. Upload it under Files > Word Files.

Run it: go to the Run tab and choose T9. A Values for this run card asks the same questions. Set From 2026-01-01, To 2026-03-31, Region East, Smallest invoice 100. Press Run.

You should see three customers (Acme Co, Cedar Ridge Garage, Eastside Tire). Each starts with "Period: 2026-01-01 to 2026-03-31 Region: East Smallest invoice: 100" and shows a total of that customer's East invoices of $100 or more.

If the filters leave no rows, you get an error, not an empty document.

Command line (same result): add --param From=2026-01-01 --param To=2026-03-31 --param Area=East --param MinAmount=100 to dp-node merge. A bad value (--param From=yesterday) exits with 3 and shows the message above.

Dates that move (used by scheduled reports, lesson 18): a parameter value starting with = is worked out when the run starts, for example =startOfLastMonth, =endOfLastMonth or =today-30d. It is a fixed list of shortcuts, never code.

13b. Several values, a date range, "(All)" and lists that depend on each other

A parameter can ask for more than one value, or two dates at once. Open sample-files/recipes/parity-parameters.recipe.json (Main table = transactions, Each record = Customer).

You should see a Parameters card with three parameters and three filters under them:

Name On the card Recipe key
Cat Category: allow several values, Offer the values of transactions.Category, Offer (All) ticked "multiple": true, "choicesFrom", "all": true
Who Customer: the values of transactions.Customer, only rows where Category matches Cat, Offer (All) "choicesFrom": { ..., "where": { "parameter": "Cat", "column": "Category" } }
BillingPeriod Type Date range, Starts as 2026-01-01..2026-06-30 "type": "dateRange"

The filters read: Category is in Cat, Customer is Who, Date is between BillingPeriod.

Try it in the preview (the Try values for the preview card):

Do this You should see
Leave everything alone Grand total $10,713.13, 5 records, ByMonth 20 rows
Category: pick Fuel and Parts (hold Ctrl) $5,970.95. Picking (All) clears the other picks, and picking another one clears (All)
Category: only Fees. Look at the Customer list It shrinks to Acme Co and Cedar Ridge Garage, the only two with Fees. Pick Acme Co: $789.00, 1 record
Category: only Tires, then Customer Cedar Ridge Garage The Customer list is Birch & Sons, Cedar Ridge Garage and Eastside Tire. The total is $661.99
Category and Customer back to (All). Billing period from 2026-02-01 to 2026-03-31 $4,415.05, ByMonth 7 rows
Clear the from date, and set to 2026-02-28 $2,724.25 and 4 records (Eastside Tire has nothing that early). An empty end means "no limit"

The Run tab has the same questions in Values for this run, and changing Category changes the Customer list there too.

How the values are written. A value is always text, on the screen, in a job file and on the command line:

Kind Written as Example
Several values Items with \| between them Fuel\|Parts
A date range Two dates with .. between them. Either one may be left out 2026-02-01..2026-03-31, ..2026-02-28, 2026-03-01..
"(All)" The word itself (it is not case-sensitive). It means no filter (All)

On the command line, put the value in quotes because of the |:

dp-node prep --data transactions.csv --detail "customers=customers.csv@Customer" --recipe parity-parameters.recipe.json ^
  --param "Cat=Fuel|Parts" --param "BillingPeriod=2026-02-01..2026-03-31" --preview

You should see 4 records, Cat = Fuel, Parts, BillingPeriod = 2026-02-01 to 2026-03-31 and GrandTotal = $1,755.95. A date range with no .. (--param BillingPeriod=2026-02-01) or with its start after its end exits with 3, and says:

Parameter 'BillingPeriod': '2026-02-01' is not a date range. Write two dates with '..' between them, such as 2026-01-01..2026-03-31 (either one may be left out).
Parameter 'BillingPeriod': the range starts (2026-03-31) after it ends (2026-02-01).

In the document, <<Cat>> prints Fuel, Parts (and nothing for (All)), <<BillingPeriod>> prints 2026-01-01 to 2026-06-30, and <<BillingPeriod_From>> and <<BillingPeriod_To>> print the two ends.

One naming rule. A parameter may not have the same name as a column in any table the report loads, because both are fields of the document. That is why this recipe says BillingPeriod, not Period: a data file with a Period column would collide. Try naming a parameter Region while customers is loaded:

Parameter 'Region': the name 'Region' is also a column in 'customers'. Rename the parameter so the merge can tell them apart.

Rename the parameter (Area, as in 13a). Every table a filter names must also be in the data you run the recipe on.


Lesson 14. Grouped layouts and sub-reports

A grouped layout groups each record's rows by one to four columns. Every group gets a header, its lines (or inner groups) and a footer of subtotals. This is the same shape as a grouped Crystal report.

Open sample-files/recipes/grouped.recipe.json (Main table = customers, Each record = Customer). The Statement item groups by Category and then by Date by month (Month). It shows the columns InvoiceNo, Date and Amount, calculates a Subtotal (total of Amount), and has a highlight rule (a subtotal over $1,000 is bold on yellow).

You should see a table in the preview with a Row column: Header 1, Header 2, Detail, Footer 2, ..., Footer 1, for each Customer, Category and Month. For Birch & Sons: Fuel (3 invoices, $831.50), Labor (2, $339.60), Tires (2, $458.25).

There are two ways to put it in a document. Use in a document shows both:

Tag Result
A finished table <<StatementTable>>{{CreateReportTable:\|}} (in its own paragraph) One report table: bold shaded header, each group on its own line, bold shaded Total rows. Sample template T8-grouped-layout.docx
Your own loops {{ForEach:Statement}} inside {{ForEach:Group2}} inside {{ForEach:Lines}} You format everything yourself. Sample template T8b-grouped-loops.docx

Here are the loops, spelled out:

{{ForEach:Statement}}                      group 1 (Category)
<<Category>>                               header 1
  {{ForEach:Group2}}                       group 2 (Month); deeper levels are Group3, Group4
  Month <<Month>>                          header 2
    {{ForEach:Lines}}                      the detail lines
    <<InvoiceNo>>   <<Date>>   <<Amount>>
    {{EndForEach}}
  Total for <<Month>>: <<Subtotal>> (<<Count>>)       footer 2
  {{EndForEach}}
Total for <<Category>>: <<Subtotal>> (<<Count>>)      footer 1
{{EndForEach}}

The text before an inner loop is that group's header. The text after it is the footer. Inside a loop, <<Name>> also finds the outer groups' values. An {{IF}} inside a loop is decided for each row (lesson 17), so you can mark one line or one group without leaving the loop.

To start one of your own, press + Grouped layout. Group by Category, and calculate a subtotal as the total of Amount (it names itself Subtotal). + Inner group adds levels, up to four.

14b. Order the groups, summary only, say it once

Four settings under the layout's More change what a grouped layout shows. Open sample-files/recipes/grouped.recipe.json again, open the Statement card, then More. A subtotal over $1,000 is still bold on yellow, as before.

Order the groups. Groups come out in natural order (Category A to Z) unless you say otherwise.

  1. Under Order the groups, press + Group order. Choose level 1, by Subtotal, biggest first.
  2. Press + Group order again. Choose level 2, by Month, biggest first.

You should see, for Birch & Sons: Fuel first (3 invoices, $831.50), then Tires (2, $458.25), then Labor (2, $339.60), where it used to be Fuel, Labor, Tires. Inside Fuel the months run 2026-05, 2026-04, 2026-01, newest first.

"groupSort": [
  { "level": 1, "by": "Subtotal", "dir": "desc" },
  { "level": 2, "by": "Month",    "dir": "desc" }
]

by is a subtotal, Count, or the level's own name (here Month). The groups of a level are ordered inside the group above it. Two groups that are still equal keep their natural order. The loops and the finished table follow the new order.

Summary only. Press + Grouped layout and name it Brief. Group by Category, add the subtotal Subtotal as the total of Amount, and add a group order (level 1, Subtotal, biggest first). Under More, tick Summary only: leave out the detail lines.

You should see only Header and Footer rows. For Acme Co the footers run Parts $1,780.50, Fees $789.00, Fuel $605.60 and Labor $408.24, each for 3 invoices. The subtotals are worked out from every invoice before the lines are dropped, so they equal the full report's. In the document, {{ForEach:Lines}} repeats zero times, and <<BriefTable>>{{CreateReportTable:|}} has only the group names and the Total rows. Make a second layout if you want both a short and a full statement.

"layout": { "groupBy": ["Category"], "subtotals": { "Subtotal": { "sum": "Amount" } }, "detail": "hide" }

Say a repeated value once. Press + Grouped layout and group by Category only. Tick the columns Category, InvoiceNo, Date and Amount under Columns shown on each line, order the lines by Date, then tick Category under Blank a value that repeats the line above. For Birch & Sons the Fuel group reads Fuel INV-1013, then two lines with a blank Category (INV-1016 and INV-1019). The value shows again at the start of the next group (Labor). It compares real values, so order the lines so that equal values sit together, and subtotals are never blanked.

"suppressRepeats": ["Category"]

Keep only some inner groups. Under Keep only groups where, add a condition: level 2, Subtotal, is more than 300. You should see, for Birch & Sons, only three months left: Fuel 2026-04 ($612.00), Labor 2026-04 ($301.20) and Tires 2026-02 ($430.75). The parents are not changed: Fuel's footer still says $831.50 for 3 invoices, because a dropped inner group leaves its parent's subtotals alone. A level 1 condition drops a whole group with everything under it.

"having": [ { "column": "Subtotal", "when": "gt", "value": 300, "level": 2 } ]

The order of work is: keep only the groups you asked for, then order them, then list the lines. A running total on the lines counts along the new order.

14c. Sub-reports: a second file linked by customer

payments.csv comes from "another system". It names the customer in a column called CustName, not Customer, and Eastside Tire has paid nothing. You want each statement to show Billed, Received and Balance.

Set up once:

  1. Add payments.csv to the same Data Set as customers and transactions. Go to Data > Data Sets, press Edit (the pencil), then Add tables, and tick payments.csv. (Use Upload more files... first if it is not listed.) No link is needed. The screen only offers tables from the Main table's own Data Set.
  2. Upload sample-files/templates/T10-subreport.docx under Files > Word Files. If you uploaded an older copy before, delete it first.
  3. Close and reopen the screen. Choose Main table customers (Reporting Test) and Each record = Customer. Tables you can summarize must list customers, transactions, payments.
  4. Press Open recipe file... and choose sample-files/recipes/subreport.recipe.json.

You should see a Sub-reports card: In payments the column CustName holds the Customer of each record. In the recipe it looks like this:

"links": { "payments": "CustName" }

There are two grouped layouts, Charges and PayLedger, and three totals: Billed, Received and Balance.

Record Billed Received Balance
Acme Co $3,583.34 $2,866.67 $716.67
Eastside Tire $857.45 $0.00 $857.45

A customer with no payments counts as $0 paid, not as an error. (A sum or count over no rows is 0 in a sub-report. min, max and tables stay empty.) On the screen, the linked column is called Customer, the record key's name, not CustName.

Run it with T10. You get five documents, each with a shaded Billed/Paid/Balance band, Charges by category as a finished table and Payments received the same way by method. Acme's Card payments total $1,791.67 and Check $1,075.00. Balances over $1,000 are red and bold. Eastside Tire has the Payments heading and no table under it.

Now make a mistake on purpose: change the linked column to CustNme. You see "Link 'payments': no column named 'CustNme' in 'payments'. Did you mean 'CustName'?"


Lesson 15. More numbers: median, percentile, rank and previous row

A total and an average do not answer every question. "What is a typical invoice?" is a median. "How big are the biggest invoices?" is a percentile. "Who comes first?" is a rank. "Is this week up on the one before?" needs the previous row. This lesson adds all four, and three new ways to group dates.

15a. More summary functions

Open sample-files/recipes/parity-statement.recipe.json (Main table = customers, Each record = Customer). Open the Stats card. It groups transactions by Customer and Category.

  1. Under Calculate, press + Calculation. Choose Median of, the column Amount, and call it Mid.
  2. Press + Calculation again. Choose Percentile of. A box at ... % appears: type 90. Choose Amount and call it P90.
  3. Open the Preview tab and look at the Stats table.

You should see, for Acme Co (the card also has Total, a count of different invoices and a standard deviation):

Category Total Mid P90 Rank
Parts 1,780.50 310.00 1,062.40 1
Fees 789.00 185.00 469.00 2
Fuel 605.60 120.50 352.10 3
Labor 408.24 98.25 227.65 4

Cedar Ridge Garage's Labor is 1,288.90 with a median of 644.45 and Rank 1. In the recipe the extra setting (here p) sits next to the function:

"measures": {
  "Total": { "sum": "Amount" },
  "Mid":   { "median": "Amount" },
  "P90":   { "percentile": "Amount", "p": 90 }
}

These are the functions in the Calculate list. The numbers are for all 12 of Acme Co's invoices (a table grouped by Customer only):

On the screen In the recipe Acme Co
Median of { "median": "Amount" } 202.50: the middle of 185.00 and 220.00
Percentile of, at 90 % { "percentile": "Amount", "p": 90 } 527.00
Nth largest of, number 2 { "nthLargest": "Amount", "n": 2 } 540.00. A repeated value counts again
Nth smallest of { "nthSmallest": "Amount", "n": 2 } The same, from the small end
Most common value of { "mode": "Amount" } 49.99. Every amount occurs once, so the lowest wins. A tie also goes to the lowest
Count of different values in { "distinct": "Category" } 4
Standard deviation of { "stdev": "Amount" } 335.23. Tick the whole population ("population": true) for 320.96
Variance of { "variance": "Amount" } The square of the standard deviation. Same population setting
Weighted average of, weighted by a column { "weightedAvg": "Price", "weights": "Quantity" } Needs a weights column, which the sample data does not have

A few things to know:

  • The percentile method is Excel's PERCENTILE.INC: sort the numbers and draw a straight line between the two neighbours of the position. Other products use other methods and give slightly different answers, so never compare a percentile with another tool's figure without checking which method it uses. The median is the 50th percentile.
  • They work where sum works: a summary table, a layout's subtotals, a total (also per record) and the value of a cross-tab. A layout's running columns keep the original seven functions. A cross-tab's Total row and column stay for sum and count.
  • Text and blanks are skipped with a yellow warning, as for a total. A standard deviation of a single number is blank.
  • They are worked out by the recipe, before the document is made. A template function cannot calculate a median, so put it in the recipe and merge the column.

15b. Rank, previous row, next row and change

These are derived columns: worked out down the rows. Open Stats, then More, then press + Moving average, growth, change, rank, RSI or MACD. Choose Rank, of Total, the biggest is 1, and call it Rank. (The sample already has it.)

"derived": [ { "of": "Total", "as": "Rank", "rank": "desc" } ]
On the screen Gives In the recipe
Rank 1 for the biggest (or the smallest, if you choose that). Ties share a rank and the next one is skipped "rank": "desc" (or "asc", or true)
Dense rank The same, but no gap after a tie "denseRank": "desc"
Value of an earlier row The row above, or N rows back. Empty on the first row "previous": true, "previous": 3
Value of a later row The row below, or N rows ahead "next": true, "next": 3
Difference from the row before This row minus the row above, in the same units "difference": true

Four rows with the values 90, 80, 80 and 70 get rank 1, 2, 2, 4 and dense rank 1, 2, 2, 3.

The rank is counted inside the record (each customer has its own 1, 2, 3), and does not depend on the order of the rows. The previous, next and difference columns follow the rows as listed, after your sort. So they are the row above, not the calendar period before. Edge rows are empty, not zero. Like the other derived columns, they cannot be sorted on or tested by "Keep only groups where".

Week by week. Press + Summary table and name it ByWeek. Group by Customer, then Date by ISO week, called Week. Calculate Weekly as the total of Amount. Under More, add Value of an earlier row of Weekly, called Prev, and Difference from the row before of Weekly, called Change.

You should see, for Acme Co:

Week Weekly Prev Change
2026-W01 120.50
2026-W02 310.00 120.50 189.50
2026-W06 75.10 310.00 -234.90
2026-W08 98.25 75.10 23.15

Acme has no invoices in weeks 3 to 5, so week 6's previous row is week 2. If you want the empty weeks, they have to be in the data.

"ByWeek": {
  "from": "transactions",
  "groupBy": ["Customer", { "week": "Date", "as": "Week" }],
  "measures": { "Weekly": { "sum": "Amount" } },
  "derived": [
    { "of": "Weekly", "as": "Prev",   "previous": true },
    { "of": "Weekly", "as": "Change", "difference": true }
  ]
}

15c. Date buckets: week, half year, day of week

A Group by date column has more choices than month and year. Every label sorts correctly as text.

Choose Label Recipe
by day 2026-01-03 { "day": "Date", "as": "Day" }
by ISO week 2026-W02 { "week": "Date", "as": "Week" }
by month 2026-01 { "month": "Date", "as": "Month" }
by quarter 2026-Q1 { "quarter": "Date", "as": "Quarter" }
by half year 2026-H1 (January to June) or 2026-H2 { "halfYear": "Date", "as": "Half" }
by year 2026 { "year": "Date", "as": "Year" }
by day of week 1-Mon ... 7-Sun { "weekday": "Date", "as": "Day" }

An ISO week starts on Monday, and its label carries the ISO year, so the first days of January can belong to the last week of the year before. A week that spans two months is one group. The number in 1-Mon makes the days sort Monday to Sunday.

Try it.

  1. Dunn's Auto Fuel in Stats: total 1,070.00, median 310.00, 90th percentile 494.00, Rank 1.
  2. Make a table grouped by day of week only, with a count of every row (Count of, every row). You should see Monday 7, Tuesday 8, Wednesday 4, Thursday 4, Friday 2, Saturday 8 and Sunday 6: 39 invoices.
  3. Group by half year as well. Every invoice is in 2026-H1, because the data runs January to June.

Lesson 16. Barcodes and label sheets (QR codes, name tags, property signs)

A barcode is a picture of a value (an invoice number, a web address) that a phone or a scanner can read. A label sheet lays many small items across a page: name tags, address labels, property signs. Both are made by the recipe and placed by the template, like charts.

16a. A QR or bar code on each record

Open sample-files/recipes/parity-statement.recipe.json and look at the Barcodes card. It has one entry:

Setting On the card Recipe key
Name Scan the name of the entry
Kind QR code (the other is Code 128 bar code) "type": "qr"
Text https://example.com/statement/{Customer:url} "pattern"

The sentence under it says it makes the picture field [[Barcode_Scan]]. To make your own, press + Barcode, name it, choose the kind, and either choose of a column, a total or a parameter, or type text with {Column} placeholders (the box + insert {field} helps). More: size is for the pixel size and a QR code's error correction.

"barcodes": {
  "Scan": { "type": "qr", "pattern": "https://example.com/statement/{Customer:url}", "moduleSize": 6 }
}

In the template, put the picture field alone in its own paragraph and set its width in points:

[[Barcode_Scan]]{{SetImageWidth:70}}

The width matters. The default is small (108 points). For sharp edges, make the width a whole multiple of the picture's squares, including the white border, and scan a printed sample before you rely on it.

Give exactly one of value and pattern.

  • value is one column of the record's data, a per-record total or a parameter: { "type": "code128", "value": "InvoiceNo" }.
  • pattern is text with {Column} placeholders. {Column} is put in as it is. {Column:url} is percent-encoded, which a web address needs: Acme Co becomes Acme%20Co and & becomes %26. Use :url for any value that sits inside a link.

You should see, after a run with T20-parity-statement (lesson 17), a QR picture on each customer's page. Open Alt Text in Word to read what it holds: QR code for https://example.com/statement/Acme%20Co for Acme Co, and QR code for https://example.com/statement/Birch%20%26%20Sons for Birch & Sons. Scan one with a phone to check. (The sample address example.com is safe to scan.)

Good to know:

  • One picture per record, not per detail line. A barcode belongs to a record (or, below, to a label), not to a row of a table.
  • A blank value gives that record no picture and a yellow warning, and the documents are still made (exit code 5 on the command line): Barcode 'Pay': 1 of 3 record(s) have no value in 'PropertyId', so they get no barcode.
  • Code 128 holds plain ASCII characters only (no accents). A value it cannot hold gets no picture and a warning. A QR code holds any text.
  • With no Each record is one choice, every row is its own record, so 39 invoices give 39 pictures of each barcode.
  • The Preview tab does not draw barcodes. Look at the finished Word file.

16b. A sheet of labels

Property signs: 11 listings, 2 signs across, and a QR code on each sign.

  1. Import sample-files/data/properties.csv (Data > Files > Data Files > Import Data File). It stands alone, so on the screen tick Show my loose data files and choose properties as the Main table.
  2. Open sample-files/recipes/parity-signs.recipe.json. Or build it: press + Label sheet, name it Signs, from properties, Labels across 2. Under Fields on each label tick PropertyId, Address and City. Under More, order the labels by City, then Address.
  3. In the Barcodes card, Scan is a QR code for each label of Signs, with the text https://example.com/request/{PropertyId}?for={Address:url}.
"tables": {
  "Signs": { "from": "properties",
             "tile": { "columns": 2, "skip": 0, "fields": ["PropertyId", "Address", "City"], "sort": ["City", "Address"] } }
},
"barcodes": {
  "Scan": { "type": "qr", "in": "Signs", "pattern": "https://example.com/request/{PropertyId}?for={Address:url}", "moduleSize": 6 }
}

You should see a Signs table of 6 rows: 11 signs, two across. Row 1 is P110 (64 River Rd, Clairton) and P105 (99 Hill Ave, Clairton). Row 2 is P103 (5 Pine Rd) and P108 (12 Mill St & Row), both Duquesne. Row 6 has only P109 (18 Cedar Ln). The cell beside it is empty.

Start part way down a used sheet. Under More: start part way down a sheet, leave 3 positions empty. You should see 7 rows: row 1 is empty, and the first cell of row 2 is empty, so the first sign (P110) is in the second cell of row 2. Put it back to 0.

In the document, the labels are one row of one Word table. The loop sits in that row, and each cell has its own numbered fields: <<Address_1>> in the first cell, <<Address_2>> in the second, and so on. The sample template is sample-files/templates/T21-property-signs.docx:

Cell What is in it
First {{ForEach:Signs}}, <<Address_1>>, <<City_1>>, then [[Barcode_Scan_1]]{{SetImageWidth:80}} in its own paragraph
Last <<Address_2>>, <<City_2>>, {{EndForEach}}, then [[Barcode_Scan_2]]{{SetImageWidth:80}} in its own paragraph

With for each label of a sheet, the picture fields are [[Barcode_Scan_1]] ... [[Barcode_Scan_N]], one for each label across, and the pattern reads the label's own fields ({PropertyId}).

You should see, after a run with T21 (Main table properties, one document): a Word file with 2 pages: 4 rows of 2 signs on page 1 and 2 rows on page 2 (the last row has one sign). It has 11 QR pictures, and the empty cell has none. The QR text for 12 Mill St & Row ends ?for=12%20Mill%20St%20%26%20Row (the & must be %26, or the link would break).

Making the Word table. The recipe repeats table rows, and Word has to hold the measurements. These settings keep the rows exact:

  1. Page. Set the paper size and margins to your sheet's, with the header and footer empty.
  2. One table with one row, and one cell for each label across. Where the sheet has a gap between labels, add an empty narrow cell with the width of the gap.
  3. Fixed layout. In Table Properties, turn off automatic resizing, and set the width of every cell.
  4. Exact row height. Set the row height to Exactly, equal to the distance from the top of one label to the top of the next. Turn off "Allow row to break across pages". (T21: 168 points, which is 2⅓ inches.)
  5. Zero margins. Set the default cell margins to 0, no borders, and paragraph spacing before and after to 0. An exact row cuts off whatever does not fit, so keep the text small enough.
  6. The loop. {{ForEach:Signs}} in the first cell, {{EndForEach}} in the last.
  7. The page body must fit the rows. Make it at least rows × row height and less than one more row. For T21 that is at least 4 × 168 = 672 points (9⅓ inches) and under 840 points. Word then starts each new sheet on its own page by itself.
  8. The paragraph after the table. Word needs one. Make it 1 point (exact line height, font size 1) and leave about 0.1 inch spare in the bottom margin, or Word may add a blank page at the end.
  9. Print at actual size. Turn off "fit to page".

We checked in real Word that the rows come out exactly as tall as set, that skip puts the first label where it should, and that there is no stray blank page. We did not check a printed sheet against real label stock. DataPublisher does not ship the measurements of any label maker's sheets. For real stock (the maker's codes), take the measurements from the package or the maker's own template, then print one sheet on plain paper and hold it against a real sheet in front of a light. The school co-op pack's name-tag sheet is built the same way, with design values only, and its notes say so.

Several sheets as separate tables (when each sheet needs its own heading): add "rowsPerSheet": 4 to the tile. The sheet name then lists sheets and each has its rows (see 05 Reference).

A warning on purpose. A label that has values but a blank column used by the barcode text gets no QR code and a yellow warning (exit code 5). Empty padded or skipped positions stay silent.

Try it.

  1. Add Status to the fields and put <<Status_1>> in the first cell. Run again.
  2. Change the pattern to https://example.com/listing/{PropertyId} (no address). The QR pictures change, the signs do not.
  3. Look at the Preview: it shows the table, not a page, and no QR picture. That is expected.

Lesson 17. Headers, footers, IF / ELSE and a page that follows the record

This lesson is about the template. No new tags were added. Existing ones now work in more places.

17a. Merge fields in headers and footers

<<Field>> and {{IF}} work in a header or footer the same way as in the body. A page number and a page count stay live Word fields. Open sample-files/templates/T20-parity-statement.docx in Word, double-click the header and look:

Where Text
Header Statement for <<Customer>> - <<Region>> region
Footer Page (page number field) of (page count field) - <<Customer>>

For the page number and count, use Word's own page fields (Insert > Page Number), or type {{PageNumber}} and {{TotalPages}}.

Then run it:

  1. Upload T20-parity-statement.docx under Files > Word Files.
  2. Open parity-statement.recipe.json (Main table = customers, Each record = Customer). On the Run tab choose T20, layout A page for each Customer, format Word, and press Run.

You should see one Word file with a section for each of the 5 customers, and each customer's pages carry that customer's own header and footer: Statement for Acme Co - East region, then Statement for Birch & Sons - West region, then Dunn's Auto (West), Cedar Ridge Garage (East) and Eastside Tire (East). The footer's last part follows the customer too. A schedule with A separate file for each Customer gives each file its own header and footer, of course.

  • With Run them together, no page breaks (records share pages), the first record's header and footer are kept for every page.
  • No loops and no pictures in a header or footer. A {{ForEach}} or [[Picture]] there is left as written, with a warning.
  • A header with only fixed text (Quarterly statement) works as it always did.
  • This works for .docx and .odt templates in server runs (the Run and Schedule tabs) and on the command line:
dp-node merge --template T20-parity-statement.docx --data customers.csv --detail "transactions=transactions.csv@Customer" ^
  --recipe parity-statement.recipe.json --out out --name "{Customer}"

That command gives 5 files, Acme Co.docx and so on. It finishes with exit code 5 and one warning, because the Mix cross-tab has no rows for two customers (lesson 12). Add --mode one-per-page (and drop --name) for one document: it holds 5 headers and 5 footers.

17b. Two-way choices: IF / ELSE

There are two forms, and both take the same test.

Total billed: <<CustomerTotal>>  ({{IF CustomerTotal > 2000 THEN "high-volume customer" ELSE "standard customer"}})
{{IF CustomerTotal > 2000 THEN}}
This customer is over 2,000, so this paragraph shows.
{{ELSE}}
This customer is 2,000 or less, so this paragraph shows instead.
{{ENDIF}}

The first is inline, inside a sentence. The second is a block that keeps the part before {{ELSE}} or the part after it, over whole paragraphs. {{ELSE}} is optional, and blocks can nest. The tests are =, !=, >, <, >=, <=. Text comparisons are exact (capital letters count) and need quotes. A number comparison needs numbers on both sides. A stray {{ELSE}} is removed with a warning.

You should see in the T20 documents:

Customer Total billed line Block paragraph
Acme Co 3583.34 (high-volume customer) over 2,000
Cedar Ridge Garage 3139.64 (high-volume customer) over 2,000
Birch & Sons 1629.35 (standard customer) 2,000 or less
Dunn's Auto 1503.35 (standard customer) 2,000 or less
Eastside Tire 857.45 (standard customer) 2,000 or less

Exactly one of the two paragraphs appears for each customer. (The total is plain here, because the total's Numbers is plain. Add {{FormatCurrency}} for dollars.)

17c. IF, dotted fields and pictures inside a loop

  • An {{IF}} inside a {{ForEach}} is decided for each row, from that row's values. T20's first table has <<Rank>> {{IF Rank = 1 THEN "(biggest)" ELSE ""}} in its last cell, so only the first row of Acme's categories says 1 (biggest). The other rows say 2, 3, 4.
  • <<Table.Field>> works inside its own loop. Inside {{ForEach:ByMonth}}, <<ByMonth.Month>> is the same as <<Month>>.
  • [[Field]] pictures work inside a loop. The row's value must be the path of a picture, for example a folder of your own pictures.

Check the rest of T20: three real tables (By category, Summary only, By week), each with a bold shaded header row that repeats on a new page and right-aligned numbers.

Try it.

  1. Run T20 as one document with A page for each Customer, then again with Run them together, no page breaks. Compare the headers.
  2. In your copy of T20, change 2000 to 3500 in both IF lines and run again. Only Acme Co (3,583.34) is high-volume now.
  3. In your copy, change the header to {{IF Region = "East" THEN "East desk" ELSE "West desk"}} and run again. Text tests need quotes and exact capitals.

What these features still do not do

  • The Preview tab does not draw QR pictures, and shows a label sheet as a table, not as pages. Look at the finished Word file.
  • A barcode is per record or per label, never per detail line.
  • Per-record headers and footers run on the server and the command line. The add-in's own Actions > Merge (Interactive mode) does not give each record its own header, and the Windows desktop merge does not do per-record headers in "one record per page" or .odt templates.
  • A table of contents in the template is kept, but is not rebuilt by the merge.
  • Percentiles, ranks and the other numbers are worked out before the document is made, not by a template function.

Lesson 18. Schedule and deliver

Use test mode and your own address for your first e-mail run. The sample customer addresses are fake.

18a. Schedule a report

A scheduled report is a saved copy of what is on the screen (summaries, data, template and values) plus a schedule. The server runs it unattended, keeps the files for 30 days, and lets you download them from the history.

  1. Open statement.recipe.json. Set Main table customers (in the Data Set) and Each record = Customer. Upload T5-statement-recipe.docx.
  2. Open the Schedule tab. Name: Statements. Template: T5. How often: Every month on day 1 at 07:00. Choose your time zone (it starts as your computer's).
  3. Files: A separate file for each Customer, named Statement_{Customer}.
  4. Under the time zone you see Next runs, the next three dates. Change How often to Every week and the dates change.
  5. Press Schedule it. You see Saved "Statements". The next run is ....
  6. Press Run now. The history shows Running, "Merging record n of 5...", then Finished, 5 records, 5 files.
  7. Download all (zip) gives you report-run.zip with Statement_Acme Co.docx and the rest.
Behavior Detail
Pause / Resume No runs happen while paused. After Resume there are no catch-up runs. The next run is the next scheduled one
Pressing Run now twice You are told the report is already running or waiting
A custom schedule A five-field cron, such as 0 7 1 * *. A bad one (every day) gives a plain message and nothing is saved
Dates that move Parameter shortcuts like Start of last month. The shortcut, not a fixed date, is saved
Editing The form fills in with its settings. It keeps the summaries it was saved with. Tick "Replace its saved summaries with the ones on this screen" to use what is on screen
Template deleted The run says Failed: "The Word template this report uses was not found." The schedule is not damaged
Delete A second press ("Really delete it and its files?") deletes the report and its history
Server down at the due time The report runs once when the server is back. It does not make up every missed run

Careful with test schedules. A cron of * * * * * runs every minute. Reset it (0 7 1 * *) or delete it when you are done.

18b. E-mail each customer their file

Tick E-mail each Customer their file. A card asks for the address column (Email), a subject (Your statement, <<Customer>>), a message, a test address and "most messages a run may send".

Because this sends real e-mail, there are safety rules:

Rule What it means
Test mode first, always A new or edited report is saved in TEST MODE. Every message goes to one test address you choose, marked [TEST], with a yellow line showing who it would have gone to. No customer is e-mailed
Arming Arm for live sending (press twice) is only possible after a test run you have looked at. Editing the report disarms it
Message limit If a run would send more than your limit, it stops at Needs approval and sends nothing until a person presses Approve and send
No address A customer with no e-mail is "skipped (no address)". The others are sent
Reconnect e-mail If your e-mail account is disconnected, the run stops, the schedule pauses, and nothing is sent
Uncertain A timeout or dropped connection mid-send stops the run as "uncertain". Check your Sent Items and say whether it went out. Resuming never sends anything twice

18c. API keys and the command line

Other software or a script can list, run and download your reports using a key (Schedule tab > API keys).

  • A key starts with dpk_, has scopes (Read, Run, Change), expires within a year (default 90 days) and can be revoked.
  • A key can never arm a report, approve a run, resume a stopped run or settle an uncertain e-mail. Those are a person's decisions.
  • The key is shown once. Copy it. It is never shown again.
  • The key goes in an environment variable, never on the command line.
set DP_API_KEY=<the key>
set DP_SERVER=https://<your DataPublisher server>
dp-node job remote list
dp-node job remote run "Statements" --wait --out C:\temp\dp-out
dp-node job remote status <run id>
dp-node job remote download <run id> --out C:\temp\zip --zip

You can also run a job file entirely on your own computer, with no server, from Windows Task Scheduler or cron:

dp-node job run statement.job.json --table transactions=transactions.csv --out out

See 05 Reference for the job file format.

A link gives one file (or a zip) to someone with no DataPublisher login, until it expires or you revoke it. Make one on the Links for other people card. Choose the report, the file, "the newest run, always" or "only the run that is newest now", and how long the link lasts. The address is shown once. A wrong, expired or revoked link all show the same plain page ("This link is not valid, or it has expired."), so nothing reveals whether a link exists.

18e. Waiting your turn

Two runs can work at once on the server, one per person. The rest wait. A waiting run tells you how many are ahead of it, starts by itself, and can be cancelled while it waits.


Where to go next

Exercises

Try Hint Check
Keep each customer's top 3 categories, with the rest as "Everything else", and chart it A summary table with top-N, then a bar chart from it. See sample-files/recipes/top-and-running.recipe.json With top 2, Acme is Parts $1,780.50, Fees $789.00, Everything else $1,013.84
Chart invoice counts by category for each customer A summary table with the count calculation, then a bar chart The counts add up to 12 for Acme
Build a Balance that turns red above $1,000 A formula total plus a highlight rule on it
Put each customer's categories biggest first, with detail lines left out A grouped layout with a group order and Summary only (lesson 14) Acme: Parts $1,780.50, Fees $789.00, Fuel $605.60, Labor $408.24
Rank each customer's categories A derived Rank on a summary table (lesson 15) Acme: Parts 1, Fees 2, Fuel 3, Labor 4
A sign for each property with a QR code A label sheet and a barcode for each label (lesson 16) 11 signs, 6 rows, 2 pages
Use your own data Use the screen's sentences as a guide: total of X, for each Y, by Z The preview makes sense to someone who isn't you

Keep going