---
title: "Formula builder: operators and variables"
description: "Every variable, operator and function you can use in the Formula dialog of a Score project, with examples and the limits we found."
url: https://youengage.me/help/formula-builder-operators-and-variables/
category: "Personalize"
type: reference
modes: [Score]
updated: 2026-12-04
verified: 2026-11-18
---

# Formula builder: operators and variables

> Every variable, operator and function you can use in the Formula dialog of a Score project, with examples and the limits we found.

## Before you start

- [Build a calculator](https://youengage.me/help/build-a-calculator.md)

The **Formula** dialog works out a result from your respondents' answers. This page lists what you can type in it. To use the dialog from start to finish, see [Build a calculator](https://youengage.me/help/build-a-calculator/).

To open it, use a Score mode project, go to the **Content** tab and click **Formula** above the canvas.

![The Formula Builder dialog with the formula round(q1a1*q2a1*0.02,2), the operator buttons under it and the list of questions on the left](https://a.storyblok.com/f/295308468495356/2732x1720/de614818e4/formula-builder-operators-and-variables-formula-dialog.png)

## Variables

A variable stands for a person's answer. Type them in lower case, as the dialog does.

| Variable | Means |
| --- | --- |
| `q1`, `q2`, `q3` ... | The question with that number in the **Questions** list on the left. For a choice question, the points of the answer the person picked. |
| `q1a1`, `q2a1` ... | The number typed into a **Number** question: `q2a1` is the first number field of question 2. |

The numbers follow the list on the left, welcome and result screens left out. A new formula starts as the sum of every variable, for example `q1a1+q2a1`.

> [!TIP]
> Typing is safer than clicking the entries in the list on the left: a click puts the variable at the start of the box, not where your cursor is.

## Operators and functions

The buttons under the box insert a template. Replace `x`, `y`, `z` and `n` with variables or numbers.

| Button | Inserts | What it does |
| --- | --- | --- |
| `+` `-` `*` `/` | `+` `-` `*` `/` | Add, subtract, multiply, divide |
| power | `power(x,y)` | x to the power of y. `power(2,3)` is 8 |
| min | `min(x,y)` | The smaller of two values |
| max | `max(x,y)` | The larger of two values |
| log | `log(x)` | The base 10 logarithm. `log(150)` is 2.176 |
| round | `round(x,n)` | Rounds to the nearest value with n decimals. Use 0 for a whole number |
| roundUp | `roundUp(x,n)` | Rounds up, towards the larger value |
| roundDown | `roundDown(x,n)` | Rounds down, towards the smaller value |
| IF statement | `x?y:z` | Gives y when x is true, otherwise z |

You can also use brackets `( )` to set the order, and plain numbers such as `0.02` in a formula.

### Conditions with IF

In `x?y:z`, x is a comparison. These worked:

| Write | Means |
| --- | --- |
| `>` and `>=` | greater than, greater than or equal to |
| `<` and `<=` | less than, less than or equal to |
| `==` | equal to |

For example `q1a1>5?10:20` gives 10 when the number in question 1 is above 5, and 20 otherwise. To check two things, put one IF inside another: `q1a1>1?(q2a1>100?10:20):30`.

### Wrap a part of the formula

Select part of the formula in the box and click a function button. The selection goes inside it: selecting `q1a1*q2a1/10` and clicking **round** gives `round(q1a1,0)`, and selecting `q1a1*q2a1` and clicking **max** gives `max(q1a1,q2a1)`. Check the result and adjust it.

## Examples

For a parcel of 2 kg that travels 150 km, with question 1 for the weight and question 2 for the distance:

| Formula | Result |
| --- | --- |
| `q1a1*q2a1` | 300 |
| `round(q1a1*q2a1*0.02,2)` | 6 |
| `round(q1a1*q2a1/7,0)` | 43 |
| `max(q1a1,q2a1)-min(q1a1,q2a1)` | 148 |
| `q1a1>1?(q2a1>100?10:20):30` | 10 |

The result is what the **@Score** chip shows on the result screen, see [Show an earlier answer or the score in a later screen](https://youengage.me/help/show-an-earlier-answer-or-the-score-in-a-later-screen/).

## Messages in the dialog

The dialog checks the formula as you type. **Save** stays off until the message is gone.

| Message starts with | What to do |
| --- | --- |
| Formula contains unresolved placeholder values | Replace `x`, `y`, `z` or `n` with a variable or a number |
| Variable "q9" refers to question 9 | Use a question number that is in the list |
| Unmatched parentheses | Close every `(` with a `)` |
| Consecutive operators found | Keep one operator between values |
| Formula cannot end with an operator | Finish the formula with a value |

## Troubleshooting

- **You clicked Save, the dialog closed, and the old formula is back.** The formula was not accepted, with no message. Formulas with `&&`, `||` or `!=` are refused, which includes what the **IF X And Y** and **IF X OR Y** buttons insert. Nest IF statements instead, as above.
- **The result screen shows no number.** `roundDown` did not give a result in our test. Use **round** or **roundUp** instead.

## Related articles

- [Build a calculator](https://youengage.me/help/build-a-calculator.md)
- [Set up scoring and result screens](https://youengage.me/help/set-up-scoring-and-result-screens.md)
