Calculated numbers

Calculated numbers

A number worked out from other numbers, never typed and never stored.

Sum and product

{
  key: "total_seats",
  type: "number",
  label,
  calculate: { sum: ["indoor_seats", "outdoor_seats"] },
}

A calculated number shows read-only, updates as people type, appears in the review and is sent to the API. The parts are other numbers in the same section.

A sum counts the parts answered so far. A product multiplies, and waits for all of them:

{ key: "area", type: "number", unit: "m²", label, calculate: { product: ["length", "width"] } }

Never stored

The answers keep null for a calculated number; the payload gets the value worked out when it is built. A saved draft therefore never holds a total that disagrees with its parts.

Try it in the tutorial: Calculated totals.