# Calculated fields

Compute scores, totals, and dynamic text from form answers.

## Calculated fields

Invisible fields that compute values from answers — quiz scores, order totals, lead ratings, or concatenated text. They update in real time as the respondent fills out the form.

<h2 id="how-it-works">How it works</h2>

<p>
  Calculated fields are invisible to respondents but compute values based on logic rules you define. They store either a{' '}
  <strong>number</strong> or <strong>text</strong> result, and update live as the respondent answers questions.
</p>

<p>
  The flow: you create a calculated field, set an initial value, then add <a href="/building-forms/conditional-logic">logic rules</a> with
  the <strong>Calculate value</strong> action. Each rule runs an operation (add, multiply, set, etc.) when its condition is met.
</p>

<h2 id="adding">Adding a calculated field</h2>

<p>
  Type <code>/</code> on an empty line and pick <strong>Calculated Field</strong> from the Layout category. It only works at the top level
  of the form — not inside a column or a repeating group. Set:
</p>

<ul>
  <li>
    <strong>Field type</strong> — number or text
  </li>
  <li>
    <strong>Name</strong> — how you refer to it in logic rules and @ mentions. It is also this field's key, so the value goes out to
    integrations and callbacks under it
  </li>
  <li>
    <strong>Initial value</strong> — the starting value before any rules fire. Either type a literal (e.g. <code>0</code> for a score) or
    pick a <a href="/building-forms/hidden-fields">hidden field</a> of the same type to seed it from a URL parameter. If the parameter is
    missing or invalid, the field starts at <code>0</code> (number) or empty (text)
  </li>
</ul>

<h2 id="numeric-operations">Numeric operations</h2>

<p>These are the exact entries in the operation picker on a Calculate value action.</p>

<h2 id="text-operations">Text operations</h2>

<h2 id="operation-values">Operation values</h2>

<p>Each operation takes a value that is either:</p>

<ul>
  <li>
    <strong>A fixed value</strong> — a specific number or string you type in (e.g. always add <strong>10</strong>)
  </li>
  <li>
    <strong>The value of another field</strong> — pick a question, hidden field, or calculated field so the value is dynamic (e.g. add
    whatever the respondent entered in Q2)
  </li>
</ul>

<p>
  A numeric operation is skipped when its value is empty or isn't a number, and dividing by 0 is skipped too, so the current total stays as
  it is. Answers to questions hidden by logic don't count — a hidden question has no value at all, so its answer never reaches a
  calculation.
</p>

<p>
  Every matching Calculate value rule runs, in document order, on the running value — they stack rather than compete. One exception to
  document order: a rule that <em>reads</em> a calculated field always runs after the rule that <em>writes</em> it, so a score is finished
  before anything branches on it. Rules that write each other's fields in a loop are flagged as a publish warning that names the chain, so
  break the loop rather than publish through it.
</p>

<h2 id="examples">Examples</h2>

<p>
  <strong>Quiz scoring</strong> — Create a calculated field "Total score" with initial value <strong>0</strong>. Add logic rules: if Q1
  equals "Yes", <strong>Add 10</strong>; if Q2 is greater than 5, <strong>Add</strong> the value of Q2. The score updates live as the
  respondent answers.
</p>

<p>
  <strong>Dynamic pricing</strong> — A product order form has a Number field for quantity and a Dropdown for size (Small, Medium, Large).
  Create a "Price" calculated field. Logic rules: if size is "Small", <strong>Set to 10</strong>; if "Medium", <strong>Set to 15</strong>;
  if "Large", <strong>Set to 20</strong>. Below those, add a rule with no conditions that <strong>Multiplies</strong> Price by the quantity
  field. Rules run top to bottom, and a rule with no conditions always runs. Pipe <strong>@Price</strong> into the thank-you page. To charge
  that calculated price directly, see <a href="/building-forms/payment-collection#dynamic-pricing">Dynamic pricing</a> in Payment
  collection.
</p>

<p>
  <strong>Lead qualification</strong> — Three Star Rating questions rate budget, timeline, and authority. A "Lead score" field uses{' '}
  <strong>Add</strong> for each rating. A logic rule checks: if Lead score is greater than 12, <strong>Set next page</strong> "Priority
  follow-up"; otherwise jump to the standard thank-you.
</p>

<p>
  <strong>Concatenating text</strong> — A text calculated field "Full name" starts empty. Logic appends <strong>@First name</strong>, then
  appends a space, then appends <strong>@Last name</strong>. Use <strong>@Full name</strong> in the thank-you page or email notifications.
</p>

> 💡 **Chain with logic**
> <p>
>     Calculated fields also work as condition sources. One rule computes a value, another reacts to it — e.g. "if Total > 50, jump to the Premium page." This lets you build multi-step scoring without any code.
>   </p>

<h2 id="pre-populating">Pre-populating other fields</h2>

<p>
  A visible field can start with a calculated field's value, so the respondent reviews a computed value instead of typing it. In a Text
  Input, Text Area, Email, Phone Number, Website URL, or Number field, type <kbd>@</kbd> at the start of the input and pick the calculated
  field. The respondent can still change the value.
</p>

<p>
  The input takes the first value the calculated field has — usually its initial value, or the hidden field that seeds it. Later changes
  from logic rules don't replace what is already in the input. To show a value that keeps updating, pipe it into text with an{' '}
  <a href="/building-forms/answer-piping">@ mention</a> instead. See{' '}
  <a href="/building-forms/field-configuration#default-values">Default values from other fields</a> for details.
</p>

<h2 id="next-steps">Next steps</h2>
<div class="not-prose grid gap-3 sm:grid-cols-2">
  - [Answer piping](/building-forms/answer-piping) — Show calculated values on the form or in emails
  - [Thank-you page](/building-forms/custom-thank-you) — Display calculated results after submission
  - [Form settings](/building-forms/form-settings) — Notifications, access control, and more
  - [Appearance & theming](/branding-domains/appearance-theming) — Theme, cover, logo, dark mode
</div>
