Overview
The Equation question type calculates a value from earlier answers and saves it in the response — a running score, a BMI, a random group number, or a tailored sentence. It supports any syntax that ExpressionScript understands.
Three things make it special:
- It computes even when hidden. Unlike every other question type, a hidden equation is still evaluated and its value stored in the database — which is exactly how it is usually used: as an invisible calculator.
- It can assign values to other questions via the assignment operator.
- No HTML is saved in the database, for security reasons.
Add and edit the question
- Click the + button and choose Equation from the Number group.
- Put your expression, in curly brackets, into the question. The cleanest way is the dedicated Equation setting in the question's settings panel — that keeps the stored value separate from the display text (and works across languages). You can then show a friendly sentence in the question text, such as "Your BMI is {self.NAOK}", while only the calculated value is saved.
- If the result is a number, also enable the Numbers only advanced setting, so the value is stored as a proper numeric variable for statistics and exports.
Common examples
Assume earlier questions have the codes weight, height, q1–q3. Give the equation question its own code (e.g. score) so you can reuse the result later.
- Total score:
{sum(q1.NAOK, q2.NAOK, q3.NAOK)} — adds up the answers.
- BMI:
{weight / (height * height)} — the classic calculation example (a ready-made sample survey is linked below).
- Random group (A/B test):
{rand(1, 2)} — randomly stores 1 or 2. Hide the question, and each respondent is randomly assigned to group 1 or group 2.
- Category from a value:
{if(score > 10, 'High', 'Low')} — stores "High" or "Low" depending on the score.
Using the result for conditions
The stored value behaves like any other answer, which makes equations the standard trick for branching logic:
- In the Condition designer ("New logic" in a later question's settings), reference the equation's code — for example, show a question group only when
rand1 equals 1, or ask follow-up questions only when score > 10.
- In later question text, pipe the value in with its code:
{score}.
Related Resources
Download the sample survey (Limesurvey_survey_BMIsample.lss.zip) to see a working BMI calculator built with this question type.
See also Use answers from previous questions (piping) for referencing codes in text, and Mask Questions for related question types.
Related Articles
Special question types: where classic "mask questions" live now
In classic LimeSurvey documentation, "mask questions" was a catch-all category for question types where the input of answers is predefined — things like Yes/No, Gender, Date/time, Numerical input, Equation, and File upload. The LimeSurvey 7 question ...
Ranking / Ranking Advanced
Overview The Ranking question type enables survey creators to present participants with a list of answers or options that respondents can arrange based on their preferences. In the new editor's question type picker, this is offered as Ranking ...
Numerical Input
Numerical Input This question type allows survey respondents to enter a single number into a text field. Related Articles Multiple Numerical Input — An extension of the numerical input question type that "allows multiple text boxes to be created, ...
Multiple Numerical Input
Overview The "Multiple Numerical Input" question type extends the standard numerical input question with several text fields, each of which accepts only numbers. Each text box corresponds to a subquestion; the subquestion text is shown as its label. ...
Single Choice Bootstrap Question
Single choice buttons The Single choice buttons question type displays each answer option as a button instead of a radio button. Participants select one answer from the predefined options. To add this question type, click the purple + button at the ...