Formulas
Overview
Section titled “Overview”A formula field calculates a number from the answers already on the form. You write the calculation once, in the form editor, and every submission of that form does the arithmetic for you.
A formula references questions, not the numbers a person typed. That is the important idea: the formula says “the cash count plus the card total”, so it stays correct no matter what anyone enters, and it keeps working after you rename the question it points at.
Formulas are calculated while the submission is being filled in, so the result updates as soon as a referenced answer changes.
Which questions a formula can reference
Section titled “Which questions a formula can reference”Only some question types can appear in a formula:
- Number
- Formula — one formula can reference another
- Checkbox — multiple choice, using each option’s score
- Confirm — using the confirmed and unconfirmed scores
- Section — sums every numeric question inside the section
- Stopwatch — contributes its value in seconds
- Sensor — contributes the sensor reading
Every other question type, such as text, dates, files and signatures, is left out of the builder’s list entirely.
For the types that are not numbers to begin with, a formula uses the answer’s score, which you set on the question’s Score tab — see Scoring and Pass/Fail.
Building a Formula
Section titled “Building a Formula”- In the form editor, add a Formula question. Dragging it from the palette opens its title editor first, so name the question before you do anything else.
- Open the question menu next to the title and click Edit.
- The editor shows an Open Formula Builder button and the note “You must build a formula before you can save.” A formula question cannot be saved without an expression.
- Click Open Formula Builder.
The builder
Section titled “The builder”The builder has two parts. The expression bar across the top holds the formula you are building. Below it, Inputs lists every question on the form that a formula is allowed to reference, with a search box for long forms.
- Click a question in the Inputs list to drop it into the expression as a token. The token carries the question’s name, so the expression reads like a sentence rather than a set of cell references.
- Type the operators directly into the expression bar:
+,-,*,/, and()to group operations. Standard order of operations applies. Those four operators and parentheses are the whole language — there are no functions.SUM(),IF(),ROUND(),MIN()and anything else you might reach for from a spreadsheet do not exist here, and typing one leaves the expression invalid. Two common substitutes:- To total a group of questions, put them in a Section and reference the section, which sums everything inside it.
- To round, use Decimal Precision on the formula question rather than a function.
- A question you have already used is greyed out in the list, but you can still add it again — the same question may appear more than once in one expression.
- Long question names are truncated in the expression bar. Hover a token to read the full name.
Validation as you build
Section titled “Validation as you build”The expression is validated on every keystroke, and the Accept button is only available while the expression is valid. When it is not, an error marker appears at the right-hand end of the expression bar describing the problem. Common cases:
- An operator with nothing after it, such as a trailing
+. - Two operators in a row.
- Two questions in a row with no operator between them.
- A formula that references itself, directly or through another formula. Formulas form a dependency graph, and a reference that would close a loop is rejected when you add it.
Click Accept to return to the question editor, which now shows the expression as a read-only preview. Click the preview to reopen the builder.
Empty answers count as zero
Section titled “Empty answers count as zero”A question that has not been answered contributes 0 to the calculation, as the builder itself notes under the Inputs list. A formula therefore always produces a number, even on a part-finished submission, rather than an error or a blank.
Decimal Precision
Section titled “Decimal Precision”Decimal Precision in the formula question’s editor sets how many decimal
places the result carries. It is applied to the calculated value, not only to
how it is displayed, so a precision of 2 both rounds the result to two decimal
places and always shows two, which is what you want for money.
A new formula question starts at 2, and 3 is the highest value it accepts.
Clear the field and the result is shown exactly as it was calculated.
Finally, click Save on the question, then Save and Publish on the form. The formula is live on the next submission.
Formulas in a submission
Section titled “Formulas in a submission”A formula question is read only while filling out a form, and says so beneath the value. Its result recalculates as the questions it references are answered, without saving or reloading anything.
Formulas inside a conditional branch are only calculated while that branch is visible.
Changing a form that has formulas
Section titled “Changing a form that has formulas”A formula depends on the questions it points at, so the form editor will not let you quietly remove one of them. Deleting, archiving or removing such a question prompts you to fix the affected formulas first — see Fixing References First.