Skip to content

Flatten By Key

Flatten By Key “unfolds” a list stored inside a record. If an order has a lines field with three products, the component returns three records, one per product, and each keeps the order’s data (number, customer, date). This way you can handle each item separately in the next steps.

When to use it

  • Each order carries a list of products and you want one row per product in a spreadsheet.
  • A customer has several addresses and you need one record per address.
  • An invoice has several lines and you want to review or classify each line.
  • An API response groups results in a list and you want to process them one by one.

Configuration

FieldWhat it does
DataThe records you want to unfold.
Key to Flatten (required)The name of the field that holds the list, for example lines.

Output

The Flattened Data output returns one record per list item, with the other fields of the original record copied into each one.

  • If each list item has its own fields (for example product and quantity), those fields move to the top level of the new record. If one has the same name as a field of the original record, the item’s value wins.
  • If the items are single values (for example, tags), each new record stores the value in the same field you named.
  • If the field holds a single value instead of a list, one record comes out.
  • Records that do not have the field are left out.

Example

A shop wants to analyse its sales by product.

Each order arrives like this: number 1001, customer López Hardware and a lines field with two products (screws, 200 units; wall plugs, 150 units).

  1. Connect the orders to Data.
  2. In Key to Flatten, type lines.
  3. The result is two records: 1001, López Hardware, screws, 200 and 1001, López Hardware, wall plugs, 150. Connect them to the component that writes to the sales sheet.