Generate rows and values
Generating means producing data that was not in the source: extra rows, one row per item of a list, sequence numbers and identifiers, or whole columns written by AI, a template, a query, or a script.
| You want | Use |
|---|---|
| An extra row next to an existing one | insertRow() |
| One row per item of a list | splitRows(list, name) |
| Row numbers and generated identifiers | rowIndex() |
| Columns an AI model fills in | eachRow().fromAi(…) |
| Text, messages, or JSON bodies | fromTemplate(…) |
| Rows reshaped in SQL, JSONata, or JSONPath | fromQuery(…) |
| Rows from JavaScript or Python | fromScript(…) |
Insert rows
Section titled “Insert rows”insertRow() adds a copy of the current row right after it. Chained .setProp calls change fields on the copy, reading the current row; every other field is copied.
Replace every trade with two legs:
do( insertRow().setProp("leg", "A"), insertRow().setProp("leg", "B").setProp("qty", 0 - prop("qty")), dropRow())
# Later statements see the inserted rows.setProp("long", prop("qty") > 0)| Input | Output |
|---|---|
T1, qty 100 |
T1, qty 100, leg A, long true and T1, qty -100, leg B, long false |
T2, qty 40 |
T2, qty 40, leg A, long true and T2, qty -40, leg B, long false |
- The inserting statement never runs over its own inserted rows; later statements see them.
insertRowis allowed insideif()anddo(), so you can insert only where a condition holds.- An inserted row keeps the lineage and exception history of the row it was copied from.
- A field only the inserted rows set exists on every row afterwards,
emptyon the rows that were not inserted.
One row per item of a list
Section titled “One row per item of a list”splitRows(list, name) emits one copy of the row per item, with the item under name. A row whose list is empty is dropped.
splitRows(prop("tags"), "tag")setProp("tag", prop("tag").upper())The list can come from a column, a JSON array, or an expression, such as split(prop("recipients"), ";") or match(prop("memo"), "[A-Z]{2}-\\d+"). Over a list of objects, each item is carried whole so .prop reads its fields. See Map and shape columns.
Number rows and build identifiers
Section titled “Number rows and build identifiers”rowIndex() is the current row’s zero-based position in the rows entering the statement:
setProp("Line", rowIndex() + 1)setProp("Batch ref", concat("B-", formatDate(today(), "YYYYMMDD"), "-", format(rowIndex() + 1).padStart(4, "0")))The second line gives B-20261122-0001, B-20261122-0002, and so on, on a run on 22 November 2026.
After a filter, sortBy, or groupBy, the position is the one that statement produced, not the order the rows arrived in; the editor warns about it. Number rows after you sort them when the numbers should follow the sort order.
Generate columns with AI
Section titled “Generate columns with AI”eachRow().fromAi(instructions) asks your deployment’s AI model once per row and writes the answer to typed columns:
eachRow().fromAi(`Classify this support ticket. Return the category that fits best, and how urgent it is.`) .send("subject", "body") .returns("category", "text", "billing, access, bug or other") .returns("urgency", "text", "high or low") .numRowsToProcess(-1).send names the columns the model sees, .returns declares each answer field with its type, and .numRowsToProcess(-1) sends every row: without it, a workflow run sends no rows, so a new AI step costs nothing until you choose. .oneToMany() turns a list answer into rows. See Ask AI in a workflow.
Generate text with templates
Section titled “Generate text with templates”eachRow().fromTemplate(jinja) renders a Jinja template per row, and without eachRow() once over all rows:
eachRow().fromTemplate(`Dear {{ row.contact }}, invoice {{ row.invoice_id }} for {{ row.amount }} {{ row.ccy }} is due on {{ row.due_date }}.`) .send("contact", "invoice_id", "amount", "ccy", "due_date")setProp("reminder", prop("rendered"))A template that renders a JSON object can fill several typed columns with .returns. See Templates, queries, and scripts.
Generate rows with a query or a script
Section titled “Generate rows with a query or a script”fromQuery(text, "sql")replaces the rows with the result of SQL over them, read as the tablerows."jsonata"and"jsonpath"work the same way.fromScript(text, "js")runs a JavaScript function per row that returns the rows replacing it: none to drop it, one to replace it, several to fan it out."python"runs Python.
A query keeps no per-cell lineage or data styles, and a script gives each output cell the styles of its whole input row, so prefer formula statements where they can do the job. See Templates, queries, and scripts.
Related
Section titled “Related”- Ask AI in a workflow
- Templates, queries, and scripts
- Worked examples:
insertRow-two-legs,splitRows-one-per-tag