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

# Quiz Formulas: Calculate Results from Answers

> Build formulas in LanderLab quiz funnels to calculate values from quiz answers and show personalized results in any step. Name, reuse, and test each formula with live values.

Formulas let you turn quiz answers into a calculated value. You combine one or more answers with math, then show the result inside any step or use it in your rules. A common use is a live estimate, like a savings figure or a running total, that updates based on what each visitor selects.

## Where to find formulas

Open your quiz in the editor and click the **Formulas** icon in the left sidebar. The panel starts empty. Click **Add Formula** to open the formula editor.

<img src="https://mintcdn.com/landerlab-babdc23f/r7Zh2MPRSmzJr3wD/images/add-formula.png?fit=max&auto=format&n=r7Zh2MPRSmzJr3wD&q=85&s=7b6466d980b595166cd7d4921907a7ec" alt="Add Formula" width="1920" height="958" data-path="images/add-formula.png" />

## Build a formula

The formula editor has three parts: general settings, the expression, and a live test.

<Frame>
  <img src="https://mintcdn.com/landerlab-babdc23f/XJDaZ6ILyLkk7ClU/images/naming.png?fit=max&auto=format&n=XJDaZ6ILyLkk7ClU&q=85&s=a2251afaef06fed97af8f3add2bf4eae" alt="Naming" width="1920" height="956" data-path="images/naming.png" />
</Frame>

### Name

Give the formula a clear name. The name is how you reference the formula later, so a descriptive one makes it easy to reuse across steps. For example, name a formula `Estimated Savings` instead of leaving it as `Formula 1`.

### Decimals

Choose how many decimal places the result shows. Use `0` for whole numbers like a dollar total, or `2` for values that need cents.

### Fallback

Set a value to show when the formula cannot return a valid result, for example when a number field is empty or an answer is missing. The fallback keeps a blank or broken value from ever reaching the visitor.

***

### Expression

The expression is where you build the calculation. Type it directly or use the buttons above the field.

<img src="https://mintcdn.com/landerlab-babdc23f/XpG_XlFI-vAvUO_O/images/Expression.png?fit=max&auto=format&n=XpG_XlFI-vAvUO_O&q=85&s=081548b9c9f7aafdbcddcf80e85bf1aa" alt="Expression" width="1920" height="956" data-path="images/Expression.png" />

* Operators: `+`, `-`, `*`, `/`, `%` (remainder), `**` (power), and `( )` to group parts of the calculation
* Functions: `min()`, `max()`, `round()`, `floor()`, `ceil()`, `abs()`, `sqrt()`

To add an answer to the calculation, click the **variable** button (the `{ }` icon) and pick a field. The list shows every field you have created in the quiz, and the one you choose is inserted as a variable, like `{{Amount}}`.

<img src="https://mintcdn.com/landerlab-babdc23f/XJDaZ6ILyLkk7ClU/images/image-42.png?fit=max&auto=format&n=XJDaZ6ILyLkk7ClU&q=85&s=4508efa7c742d7c71a08798db6efbd01" alt="Image" width="1922" height="956" data-path="images/image-42.png" />

<Note>
  The field you insert must hold a **number** for the math to work. A choice or input that stores a number, such as a price or an amount, calculates correctly. A plain text answer does not.
</Note>

For example, to double the amount a visitor entered, insert the **Amount** field and multiply it:

```text theme={null}
{{Amount}} * 2
```

***

### Test

The **Test** section previews the result with sample values before you publish. Enter a value for each variable in your expression and LanderLab shows the calculated **Result** right away. Using the expression above, an `Amount` of `2000` returns a result of `4000`.

***

## Use a formula in a step

Once saved, a formula can go into any text field in your quiz, such as a step title, a paragraph, or a button.

<Frame>
  <img src="https://mintcdn.com/landerlab-babdc23f/uXYM9xg2v-5XftzT/images/use-formula.png?fit=max&auto=format&n=uXYM9xg2v-5XftzT&q=85&s=3556ff2e974ca9c88d109737c95a34b9" alt="Use Formula" width="1917" height="958" data-path="images/use-formula.png" />
</Frame>

You have two ways to insert it:

* **Type it.** Reference the formula by name with the `{{= }}` syntax, for example `{{=Formula 1}}`
* **Pick it.** Click the **variable** button in the text field, scroll to the **Formulas** section, and select your formula

<img src="https://mintcdn.com/landerlab-babdc23f/uXYM9xg2v-5XftzT/images/variable.png?fit=max&auto=format&n=uXYM9xg2v-5XftzT&q=85&s=31a05c5528809a50682f01446adf037f" alt="Variable" width="1922" height="956" data-path="images/variable.png" />

The result is calculated live as the visitor moves through the quiz, so the value always reflects the answers they gave. A step title might read:

```text theme={null}
Your estimated savings: ${{=Formula 1}}
```

## Preview and test

To see the formula working, click **Preview** and complete the quiz as a visitor would. The result appears in the step where you placed it, using the answers you selected along the way.

## Tips

* Name every formula clearly so it is easy to find and reuse
* Set a fallback so visitors never see a blank or broken value
* Only reference fields that store numbers
* Test with realistic values before you publish
