> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getflowpilot.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculated values and answer scores

> Turn a user's answers into a number, then derive a result from it. Answer scores attach a number to each choice; calculated values compute a result you can show with a variable.

Two features let a flow do light arithmetic on what the user answers, so you can show a personalized number like "you'll spend 27 years on your phone" or "your plan saves \$1,240 a year":

* **Answer scores** attach a number to each answer option, exposing a [variable](/editor/variables) you can feed into a calculation.
* **Calculated values** are variables computed from other variables with a guided formula builder.

Neither adds anything new to the SDKs. A calculated value renders through the normal `{{variable}}` text path, and the computation runs as a managed action on the device the SDKs already support.

## Answer scores

A choice question normally just records which option the user picked. Answer scores let it also produce a **number**, without changing what the choice variable stores.

In the choice [block controller](/editor/block-controllers) there is an **"Answer values"** section with a toggle **"Use answers in a calculation"**: "Give each answer a number, then reference it in a Calculated value." Turning it on adds a small **#** field to every option, where you type that answer's number.

This is editable in [Simple mode](/editor/editing-modes), on the choice controller.

### How scoring behaves

* It is **non-destructive**. The choice variable still stores its `option_N` value. Scoring adds a separate, managed **number** variable on the side, named by the **"Variable name"** field (default "Answer score").
* **Single-select**: the score variable holds the picked answer's number. "The picked answer's number becomes a Calculated-value operand."
* **Multi-select**: the score variable holds the sum of the selected answers' numbers. Leave every number at 1 to make it count selections.

### Example

A question "How many hours a day on your phone?" with options scored 2, 4, 6, 8 exposes a number variable, say `phone_hours`, holding the picked number. You then feed `phone_hours` into a calculated value.

## Calculated values

A calculated value is a variable whose value is **computed from other variables**. You create one in the [variable manager](/editor/variables) by setting the variable's type to **Calculated** ("Computed from other variables (e.g. "27 years")").

The variable manager is an Advanced-mode surface, so you build calculated values in [Advanced](/editor/editing-modes). The numbers they usually consume (answer scores) can still be set in Simple.

### The guided formula builder

The default editor is a guided, left-to-right **"Formula"** builder, so you do not have to write an expression:

<Steps>
  <Step title="Set the first term">
    The first row starts the formula (its placeholder reads "start"). Pick a variable or type a number.
  </Step>

  <Step title="Add steps">
    Click **Add step** to add a row. Each row has an operator (**+**, **−**, **×**, **÷**) and another variable or number.
  </Step>

  <Step title="Choose rounding">
    The **Result** control rounds the output: **Whole number**, **Round down**, **Round up**, or **No rounding**.
  </Step>
</Steps>

<Warning>
  The formula runs **left to right with no operator precedence**: `2 + 3 × 4` is `(2 + 3) × 4 = 20`, not `14`. To control grouping, use the raw-expression escape hatch and add parentheses.
</Warning>

### The raw-expression escape hatch (Advanced)

For more control, toggle **"Edit as expression (advanced)"** to write a [FlowExpression](/reference/conditions-and-expressions) directly (toggle back with "← Back to guided builder"). It supports multi-operator chains, parentheses, and the functions `round()`, `floor()`, `ceil()`, and `abs()`. Reference variables by name, for example:

```text theme={null}
round(phone_hours * 365 * 50 / 24 / 365)
```

### Showing the result

A calculated value is just a variable. Show it anywhere text is rendered by interpolating it: put `{{your_variable}}` in a Title or Normal Text block.

```text theme={null}
You'll spend {{years_on_phone}} years on your phone.
```

### How it runs on the device

You do not wire anything up. When you create a calculated value, the editor compiles the formula and attaches a **managed `assign` action** to the consuming screen's appear event, so the number is recomputed each time that screen shows. The SDKs already execute `assign` actions, so calculated values need no new runtime. See [Conditions and expressions](/reference/conditions-and-expressions) for the expression grammar.

<Note>
  In this version, a calculated value cannot reference another calculated value. Compute from captured and answer-score variables.
</Note>

## Common mistakes

* **Assuming math precedence.** The guided builder is strictly left to right. Reorder the steps, or switch to the raw expression and add parentheses.
* **Scoring a multi-select and expecting one number.** A multi-select score is the **sum** of the selected options. Use single-select if you want exactly one number.
* **Renaming the score or calculated variable, then losing the reference.** Other features read it by key. Rename consistently in the variable manager.
* **Putting a calculated value on a screen that never shows.** The value is recomputed when its screen appears. Reference it on or after the screen where its inputs are collected.

## Related pages

* [Variables](/editor/variables)
* [Dynamic (conditional) values](/editor/dynamic-values)
* [Block controllers (Simple)](/editor/block-controllers)
* [Conditions and expressions](/reference/conditions-and-expressions)
