# Calculated fields

Work out scores, totals, and text from form answers. Give a calculated field a starting value, then change it with logic rules as respondents answer.

## How it works

A calculated field holds a number or a text. It starts at an initial value, and [logic rules](https://formstep.io/docs/building-forms/conditional-logic/) with the **Calculate value** action change it, for example add 10 when an answer is Yes.

## Add a calculated field

Click **Calculated Field** in the Blocks tab, or type `/` and pick it. It cannot go inside a column or a repeating group. Then set:

- **Field type**: number or text.

- **Name**: used in logic and @ mentions, and as its field key in integrations.

- **Initial value**: a value such as `0`, or a [hidden field](https://formstep.io/docs/building-forms/hidden-fields/) of the same type.

## Operations

| Field type | Operations |
| - | - |
| Number | add, subtract, multiply, divide, set to, reset to initial |
| Text | set to, append text, prepend text, reset to initial |

Each operation takes a fixed value, such as 10, or the value of another question or field. Answers to questions hidden by logic do not count. Every matching rule runs, top to bottom, on the running value.

## Examples

For a quiz score, “Total score” starts at 0. One rule adds 10 when Q1 is “Yes”, and another adds the value of Q2 when Q2 is greater than 5.

For a price, one rule sets Price to 10 when size is “Small”, and another sets it to 20 when size is “Large”. A last rule with no conditions multiplies Price by the quantity, since a rule with no conditions always runs. To charge this price, see [Change the price with logic](https://formstep.io/docs/building-forms/payment-collection/#dynamic-pricing).

For a full name, a text field appends @First name, a space, and @Last name.

Logic can also read a calculated field, for example “when Total is greater than 50, go to the Premium page”. To show the value to the respondent, use an [@ mention](https://formstep.io/docs/building-forms/answer-piping/). To start a question with it, see [Default values from other fields](https://formstep.io/docs/building-forms/field-configuration/#default-values).

## Next steps

[Conditional logic](https://formstep.io/docs/building-forms/conditional-logic/) — The rules that change a calculated field

[Change the price with logic](https://formstep.io/docs/building-forms/payment-collection/#dynamic-pricing) — Charge the price your form works out
