Skip to main content

Flatten

Flatten

The Flatten node expands array values into individual rows. When an incoming row contains a field that is an array, Flatten produces one output row per element of that array, copying the row's other fields onto each one.

It is the natural counterpart to Map: Map builds nested arrays, while Flatten unpacks them back into flat rows.

When to use it

Nested data is common when reading from APIs, OData services, or JSON documents. A single order might arrive as one record with a lineItems array:

{
"orderId": "SO-1001",
"customer": "Acme",
"lineItems": [
{ "sku": "A-1", "qty": 2 },
{ "sku": "B-7", "qty": 5 }
]
}

Flattening lineItems turns that one record into one row per line item, with the order-level fields repeated:

orderIdcustomerskuqty
SO-1001AcmeA-12
SO-1001AcmeB-75

This is the shape most Function nodes, Responses, and Dashboards expect — flat rows, one record per line.

Adding a Flatten

  1. Drag Flatten from the Functions section of the Element Panel.
  2. Connect it to the upstream node that produces the nested data.
  3. Open the panel and choose which array field to expand. Nested arrays can be expanded too — each level multiplies the rows.

Things to keep in mind

  • Row count grows. Flattening multiplies rows by the array length. A record with a 50-element array becomes 50 rows. Flattening several arrays multiplies their lengths together, so flatten only what you need.
  • Empty arrays. A row whose array is empty or missing contributes no output rows for that branch.
  • Order-level fields repeat. Fields outside the flattened array are copied onto every resulting row.

Next steps

  • Map — reshape flat rows into nested structures
  • Formula — compute columns after flattening
  • Group By — re-aggregate flattened rows