# Build a calculation

> The drag-and-drop Formula editor — and when to reach for the Code or Matrix style instead.

Source: CBX documentation, version 3.x (released). Canonical page: https://docs.configbox.at/docs/admin-guide/pricing/build-a-calculation. Last updated 2026-08-02.

---
> **Audience:** store admins · **Scope:** creating a calculation and attaching it · **Last reviewed:** 2026-07-20

**What this does** — Creates a named formula that turns the customer's current selections into a
number, and wires it into a price (or weight, or an input bound). Example built below: an area
price — *entry in Width × entry in Height × 0.20*.

## Before you start

- Read [where prices come from](https://docs.configbox.at/docs/admin-guide/pricing/where-prices-come-from) so the calculation lands in the right
  place.
- The questions the formula reads must exist.

## Steps

1. Go to **Calculations**, click **Add**, name the calculation (you'll pick it by this name
   later), choose the **product** it belongs to and the style **Formula**.
2. Build the expression in the editor:

   ![The formula editor with an area-price formula](./img/calculation-formula.jpeg)

   - Drag **Calculation Terms** into the Calculation area: the arithmetic chips
     (**+ − * /**), a **Number** chip (type its value, e.g. `0.20`), and terms from the tabs:
     - **Questions** — pick a question to drag in its **Entry** (what the customer
       entered/selected), its **price**, or its custom fields. Each question term has a small
       **"or …"** box — the fallback value used while the question has no entry yet; set it
       (usually `0` or `1`) so the price never shows blank.
     - **Calculations** — the result of another calculation of this product; this is how you
       compose small readable pieces instead of one monster formula.
     - **Customer** — values from the customer's group, for segment-dependent math.
     - **Functions** — **Round**, **Lowest value**, **Highest value** (and any store-specific
       extras): each parameter is a slot you drop further terms into.
   - Arrange chips left-to-right; normal arithmetic precedence applies, and **Put in
     parentheses** groups selected chips. **Remove selected** deletes; **Limit term width**
     compacts long chips.
3. **Save**.
4. Attach it — nothing happens until you do:
   - Open the question (or answer) → **Calculations** section → pick the calculation as its
     **Price Calculation** (or Recurring Price / Weight Calculation), or
   - use it as a **Calculated Minimum/Maximum Value** on a numeric question, or
   - reference it from a [rule](https://docs.configbox.at/docs/admin-guide/rules/build-a-rule) ("Results of calculations") or from
     another calculation.

   ![The whole question form, with the Calculations section's price and weight assignments highlighted](./img/attach-calculation.jpeg)

5. Check it live: open the configurator, change the inputs, watch the price move.

## The special "Regarding Question" term

In the Questions tab, **Regarding Question** means "whatever question this calculation is
attached to". A calculation built with it (e.g. `Entry in Regarding Question × 2.5`) can be
attached to many questions at once and always reads *its own* question — one formula instead of
ten near-copies.

## When Formula isn't the right style

- **Code** — a typed expression, faster for totals-based math ("12% of the running total") and
  for formulas easier typed than dragged: bind questions to placeholders `A`–`D` and write
  `A * B / 1000000 * 65`. Keywords give access to totals, question entries/prices and other
  calculations. → **[Write a code expression](https://docs.configbox.at/docs/admin-guide/pricing/write-a-code-expression)**
- **Matrix** — a lookup table when pricing *is* a table: choose what keys the **rows** and
  **columns** (a question's value or a calculation's result), fill the grid (or import an Excel
  file), and pick the matching mode — exact value, or round up/down to the **next bracket**.
  Multipliers can scale the looked-up cell by a quantity question or another calculation.
  → **[Price with a matrix](https://docs.configbox.at/docs/admin-guide/pricing/price-with-a-matrix)**

All three styles attach identically (step 4) and can reference each other.

## Good to know

- **Compose, don't inflate**: several small named calculations referencing each other stay
  debuggable; one giant formula doesn't.
- Calculations recompute on **every selection change** — very deep chains can slow the
  configurator.
- The calculation edit form lists **where it is in use** — check before changing shared pieces.
- Copying a product copies its calculations and re-points every reference automatically.
- Author in the **base currency**; never bake tax or currency conversion into a formula.
