Calculations & Formula Reference
A calculation is a named formula that FluoTest works out from a respondent's answers when they submit the quiz, for example a return on ad spend or a monthly saving. This page lists everything a formula can contain and how the result is stored and sent on. Calculations are free on every plan.
Last updated
What can a FluoTest formula contain?
Numbers, the operators + - * / and brackets, the comparisons > < >= <= = and !=, the functions min, max, round, abs and if, the variable keys of your questions, the keys of other calculations, and score references such as @score.percent. A missing answer or a division by zero gives an empty result, never an error.
What a formula can read#
A formula reads answers through variable keys. Give a question a variable key in the editor (the "Variable key (for calculations)" field on the question) and use that name in the formula. Keys are lowercase letters, numbers and underscores, start with a letter, are at most 40 characters long and are unique on the quiz. A formula can also read another calculation by its key, in any order.
| Question type | Value in the formula |
|---|---|
| Number, Slider | The number the respondent entered. A decimal comma is accepted (2,5 is read as 2.5). |
| Yes/No, Multiple Choice, Multi-Select, Likert, Star | The points the answer earned, with the question's weight and Reverse score applied, exactly as the score counts them. On a quiz with several scores, the points are added up across the scores. |
| Open Text, Name, Email, Phone, Website URL, Date, File Upload | Cannot have a variable key. |
| Any question that was skipped or hidden by a show-if rule | Empty. |
Score references#
A formula can read the quiz's scores. Score references start with @score.
| Reference | Value |
|---|---|
| @score.percent | The overall score as a whole-number percent from 0 to 100. |
| @score.total | The overall points: the total of all scores. |
| @score.max | The highest overall points that can be reached. |
| @score.<category> | The points of one score category, by its key, for example @score.fit. |
| @score.<category>.percent | That category's score as a whole-number percent. |
Operators#
Multiplication and division are worked out before addition and subtraction, and brackets come first. A comparison gives 1 when it is true and 0 when it is false, and a formula can hold one comparison per pair of brackets: write (a > b) + (c > d), not a > b > c. Two numbers that differ only by a rounding error in the last decimals count as equal.
| Operator | Meaning |
|---|---|
| + - * / | Add, subtract, multiply, divide. The characters × · ÷ and − are accepted too. |
| -x | A negative value, for example -fee. |
| ( ) | Brackets, up to 40 levels deep. |
| > < >= <= | Greater than, less than, at least, at most. |
| = != | Equal, not equal. == is read as =. |
Write numbers with a point for decimals (1.5 or .5), without thousands separators, a currency symbol or a percent sign. A comma separates the values of a function. There is no power operator and no text handling.
Functions#
There are five functions. Their names can be written in any case. A function name can't be used as a key.
| Function | What it does |
|---|---|
| min(a, b, …) | The lowest of 1 to 20 values. |
| max(a, b, …) | The highest of 1 to 20 values. |
| round(x) or round(x, decimals) | Rounds to a whole number, or to the given number of decimals (0 to 10). Halves round away from zero: round(2.5) is 3 and round(1.005, 2) is 1.01. |
| abs(x) | The value without its sign. |
| if(condition, a, b) | Gives a when the condition is true (any value other than 0) and b when it is not. Only the branch that is used is worked out, so if(leads > 0, spend / leads, 0) never divides by zero. |
Examples#
Each line is one calculation: its key, then its formula. The names used here (revenue, ad_spend, leads and so on) are variable keys of number questions.
roas = revenue / ad_spend profit = revenue - ad_spend - other_costs margin = (revenue - cost) / revenue cost_per_lead = if(leads > 0, ad_spend / leads, 0) yearly_saving = round(hours_per_week * hourly_rate * 52, 2) discount = min(max(order_value * 0.1, 5), 50) gap_to_target = abs(target - actual) bonus_points = if(@score.percent >= 70, 10, 0) + (team_size > 10) * 5
Empty results#
A calculation never fails a submission. When it can't be worked out, its result is empty.
- A result is empty when the formula reads a question that was skipped or hidden, divides by zero, reads a name that doesn't exist, is part of a circular reference, or can't be read at all.
- Empty spreads: any sum, comparison or function that reads an empty value is empty too. That includes if: when its condition reads an empty value, the result is empty.
- An empty result is left out for respondents, is null in webhooks and stays empty in exports and mapped fields.
- An empty result never matches an outcome rule and never disqualifies anyone.
Formats#
Each calculation has a format: number, percent or currency, with 0 to 6 decimals. Percent shows a ratio, so 0.25 is shown as 25%: write (revenue - cost) / revenue and don't multiply by 100. Currency takes your own symbol, up to 8 characters. The format only changes how the value is shown. Webhooks, exports, mapped fields and rules always use the plain number, so a rule on a percent calculation compares with the ratio (0.25 for 25%).
Limits#
| Limit | Value |
|---|---|
| Calculations per quiz | 50 |
| Formula length | 500 characters |
| Key length | 40 characters |
| Name length | 120 characters |
| Nested brackets and function calls | 40 levels |
| Decimals shown | 0 to 6 |
Where the values go#
Values are worked out on FluoTest's servers when the response is submitted and stored with it, together with the calculation's name and format at that moment. Changing a formula later never changes an old response.
- Result page, shareable results page and PDF report: every calculation with "Show to respondents" on.
- Copy: @calc.<key> in result messages, tier messages, the results email and links. In a link the plain number is inserted.
- Results: an outcome rule of type Calculation (at least, more than, at most, less than, exactly or between), and "Disqualify on this number" on the calculation itself.
- Webhooks: the calculations object, by key. Field mapping: one calc:<key> source per calculation. CSV export: one column per calculation.
- MCP and quiz files: the calculations list on the quiz (key, name, formula, format, currency_symbol, decimals, show_to_respondent, disqualify), variable_key on a question, and outcome rules with type "calculation".
Frequently asked questions#
Are calculations free?
Yes. Formulas, the calculator templates and results based on a calculation are available on every plan, including Free.
Can a formula check whether a question was answered?
No. A formula that reads a skipped question is empty, and so is an if whose condition reads it. Make the question required when a calculation depends on it.
Why does my percent show 2500%?
The percent format expects a ratio. 0.25 is shown as 25%, so a formula that already multiplies by 100 is shown a hundred times too high. Remove the * 100.
Can one calculation use another?
Yes, by its key, and the order in the list doesn't matter. A calculation that ends up reading itself is flagged in the editor as a circular reference and gives an empty result.
Do old responses change when I edit a formula?
No. Each response keeps the values that were worked out when it was submitted.