Create calculated variables based on other answers.
COMPUTE: variable = expression to calculate a variableSHOW_IF: on any block, page, section, or question can reference a computed variable from any block, not just its own# **Monthly Expenses**
Q: Monthly rent
NUMBER
VARIABLE: rent
Q: Monthly food
NUMBER
VARIABLE: food
Q: Monthly transport
NUMBER
VARIABLE: transport
BLOCK: Summary
COMPUTE: total = rent + food + transport
# **Budget Summary**
Your total monthly expenses: **{total}**Monthly Expenses
Monthly rent
Monthly food
Monthly transport
Comparisons can be summed the same way — each variable == value term counts as 1 or 0, so adding several together counts how many matched. Useful for tallying how many checkbox-style questions someone answered a certain way.
# Hazards
Q: Extreme heat
- Yes
- No
VARIABLE: heat
Q: Extreme cold
- Yes
- No
VARIABLE: cold
Q: Severe weather
- Yes
- No
VARIABLE: severe
# Result
COMPUTE: hazard_total = heat == Yes + cold == Yes + severe == Yes
You reported **{hazard_total}** hazard(s).Hazards
Extreme heat
Extreme cold
Severe weather
Use IF <condition> THEN <value> ELSE <value> to assign a value based on a condition. The condition uses the same syntax as SHOW_IF. Values can be quoted strings, numbers, or references to other variables.
SHOW_IF comparisons on pages, sections, or questions# Satisfaction
Q: How satisfied are you? (1-10)
NUMBER
VARIABLE: score
# Result
COMPUTE: level = IF score >= 8 THEN "High" ELSE "Low"
Your satisfaction level: **{level}**Satisfaction
How satisfied are you? (1-10)
For more than two outcomes, use either ELSE IF chaining in a single expression, or multiple COMPUTE statements for the same variable.
With multiple statements, start with a default value and override it with conditions in increasing specificity. Each statement is evaluated in order — a condition that is false leaves the current value unchanged.
# Satisfaction
Q: How satisfied are you? (1-10)
NUMBER
VARIABLE: score
# Result
COMPUTE: level = "Low"
COMPUTE: level = IF score >= 5 THEN "Medium"
COMPUTE: level = IF score >= 8 THEN "High"
Your satisfaction level: **{level}**Satisfaction
How satisfied are you? (1-10)
Alternatively, write it as a single chained expression:
# Satisfaction
Q: How satisfied are you? (1-10)
NUMBER
VARIABLE: score
# Result
COMPUTE: level = IF score >= 8 THEN "High" ELSE IF score >= 5 THEN "Medium" ELSE "Low"
Your satisfaction level: **{level}**Satisfaction
How satisfied are you? (1-10)