Skip to main content

Video tutorial

How calculations work

A calculation works out a value from your respondents’ answers while they fill in the form, like an order total, a score or someone’s age. You can show the result on the form, use it as a payment amount, or send it to your integrations. Instead of one formula, a calculation is built from rules:
  1. It starts from an Initial value, like a number you type or an answer from the form.
  2. Each rule changes that value with one operation, like add or multiply by.
  3. The rules run in order, top to bottom, and each one works on the result of the rule above it.
For example, (A + B) × C is two rules: start from A, add B, then multiply by C. Each rule takes one value. If you put several references in one value box, like @A + @B, Fillout reads it as text and skips the rule. Add a separate rule for each field instead. A rule with an empty value is skipped too, so it doesn’t count as 0.

Add a calculation

In this example, a coffee order form asks for a Size (Small or Large) and How many?. A Total price calculation works out the price: $3 for each small coffee and $4 for each large one. Here’s the whole flow, from opening Logic to adding your first rule:
1

Open Calculations

In the form editor, click Logic at the bottom right, then open the Calculations tab and click Add new calculation.
2

Name the calculation and choose a type

Enter a Name, like Total price, and choose a Type:
  • Number - for prices, scores and other numbers
  • Text - for a message or label that changes with the answers
  • Duration - for the time between two dates or times, like an age or hours worked. See Calculate the time between dates or times.
Then click Create calculation.
New calculation with the Name Total price and the Type number
3

Set the initial value

The Initial value is where the calculation starts. Type a number, or click the plus icon to start from an answer. In this example, it starts from How many?.A Number calculation with an empty Initial value starts at 0. The same applies when the initial value is a question the respondent left empty.
Total price calculation with How many? as its Initial value
For a Number calculation, Decimal places sets how the result is rounded:
  • Auto - rounds to 2 decimal places and drops trailing zeros, so 67.40 shows as 67.4
  • 0 to 4 decimals - rounds the result and always shows that many decimals, so with 2 decimals, 67.4 shows as 67.40
Decimal places dropdown with Auto and 0 to 4 decimals
Showing a price? Choose 2 decimals so an amount like 67.40 keeps its trailing zero.
4

Add rules

Click New rule. Each rule has:
  • A condition - when the rule applies, like when Size is Small. Click Set conditional logic, then Add condition, and pick the question, how to compare it and the answer. To run the rule every time, turn on Always instead.
  • An operation - add, subtract, multiply by, divide by or assign. assign replaces the value with the rule’s value. A Text calculation can only use assign.
  • A value - a number you type, or an answer or another calculation you pick with the plus icon .
For the coffee order, add two rules: when Size is Small, multiply by 3, and when Size is Large, multiply by 4.
Total price rules: the first multiplies by 3, and the second has the condition Size equals Large
To change the order of the rules, drag them.
5

Show the result and test it

Click Done and close Logic. To show the result, add a Paragraph, like “Your total: $”, type @ and pick the calculation from the Calculations tab. Then click Preview and try a few answers. Two large coffees should give 8.
Preview of the coffee order form with Large and 2 chosen, showing Your total: $8
You can also ask the Form Agent to create calculations for you.

When several rules apply

Every rule whose condition is met runs, from top to bottom. Rules don’t override each other unless they use assign: a rule with assign replaces whatever the rules above it worked out, so when several assign rules apply, the last one wins. For example, a Text calculation could assign “Thanks for your order” with Always turned on, then assign “Large drinks take about 5 minutes” when Size is Large. A respondent who picks Large sees the second message, because that rule comes last.
Pickup note rules: an Always rule that assigns Thanks for your order, then a rule with a condition that assigns Large drinks take about 5 minutes

How results are displayed

By default, a Number result is rounded to 2 decimal places, trailing zeros are dropped (10.2, not 10.20), and no currency symbol or thousands separator is added. To change the rounding, set Decimal places in the calculation. The calculation itself can’t hold a currency symbol. To show one, type it in the Paragraph or Heading right before you insert the calculation, like “Your total: $” followed by @Total price. When an answer that a rule uses is a list, like a Checkboxes question, a Number calculation adds up the numbers in it, and a Text calculation joins the answers with commas.

Use a calculation in your form

Once a calculation exists, type @ or click the plus icon anywhere you can reference answers, then open the Calculations tab .
Paragraph with Your total: $ and the @ menu open on the Calculations tab, listing Total price and Pickup note

Show the result on a page

On a Heading or Paragraph, type @ and pick the calculation. See Answer piping. You can style this text by selecting it and changing the font size, weight or color.

Set a payment amount

On a payment page, reference the calculation in the product’s price, so the amount changes with the order. See Dynamic payment.

Pre-fill fields with a calculation

Open a question’s settings . Under Default value, click the plus icon and pick the calculation. See Pre-fill fields.

Send it in emails and integrations

Calculations are saved with each submission. You can reference them in custom emails, including the subject line, in workflows, and in your integration mappings.

Block submission based on a calculation

Calculations have no validation setting of their own. To stop respondents from submitting unless a calculation meets a rule, like an order total of at least 10:
  1. Open the settings of a question respondents must answer.
  2. Turn on Required. Questions that aren’t required and are left empty skip validation.
  3. Under Validation, set the validation pattern to Condition and add a condition that references the calculation.
  4. Add an Error message that tells respondents what to change.
See Form validation for which questions have a Condition pattern.

Calculation recipes

Combine calculations

Each rule does one operation, so a formula like (A × B) + (C × D) needs more than one calculation:
  1. Add a Number calculation that starts from A and has a rule that will multiply by B.
  2. Add a second Number calculation that starts from C and has a rule that will multiply by D.
  3. Add a third Number calculation. For its Initial value, click the plus icon, then the calculator icon, and pick the first calculation. Add a rule that will add the second calculation.
Show the third calculation on your form. A calculation can use other calculations this way, so you can build up longer formulas, like a price that adds several items.

Calculate a percentage

Add a Number calculation that starts from the value. Add a rule that will divide by the total, then another that will multiply by 100. Turn on Always for both rules so they run every time. For example, for a 10-question quiz, start from Correct answers, divide by 10, then multiply by 100. A respondent with 7 correct answers gets 70.
Number calculation Score percentage that starts from Correct answers, divides by 10 and multiplies by 100, with Always on for both rules

Calculate quiz scores

You don’t need a calculation for quiz scores. Fillout works out the score and lets you show it on any page. You can also use weighted scoring and assign results based on the total score.

Calculate the time between dates or times

Use a Duration calculation to work out someone’s age, how long a trip lasts, or how many hours someone worked. Pick the Start and End questions, then the Units you want the result in: years, months, weeks, days, hours or minutes. For Start or End, you can also click the calendar icon and pick a date utility, like Today or Submission time. For example, start from a date of birth and end on Today to get someone’s age. The result is always a whole number, rounded down. For example, from 1:00 PM to 4:30 PM in hours gives 3, not 3.5.
Duration calculation with Start time, End time and the units set to minutes

Get hours with decimals, or take off a break

For a timesheet, you might want 3.5 hours instead of 3, or to take off a lunch break. A Duration calculation can’t do that on its own, so add a second calculation that does the math:
  1. Add a Duration calculation in minutes. From 1:00 PM to 4:30 PM, it gives 210.
  2. Add a Number calculation. For its Initial value, pick the Duration calculation.
  3. If you ask for a break, click + New rule, choose subtract and pick the break question. With a 30-minute break, that leaves 180.
  4. Click + New rule again, choose divide by and enter 60. 210 minutes becomes 3.5 hours, or 3 hours with the break.
  5. Show the Number calculation on your form, not the Duration one.
Number calculation that starts from Minutes worked, subtracts Break (minutes) and divides by 60
To check it, click Preview and enter 1:00 PM and 4:15 PM, with no break. You should see 3.25.

What calculations can’t do

Add days to a date

Calculations can’t add days, weeks or months to a date, so they can’t work out a due date or an end date. A calculation can be Text, Number or Duration, and none of them gives a date as its result. A Duration calculation only measures the time between two dates or times. To show a date a set number of days from today, set a date field’s Default value to N days from now instead. See Pre-fill dates in your form.

Other limits

  • Take part of an answer, like a first name from a full name. A Text calculation can only set a value.
  • Generate random values or number respondents, like Respondent 1, 2, 3. Forms can’t see how many submissions they already have. Each submission gets a unique Submission ID instead.
  • Show a clickable link. A Text calculation shows as plain text. To send respondents to a link from a calculation, add a URL button to the ending page and reference the calculation in its URL. You can also select text in a Paragraph, add a link, and type @ in its URL to insert the calculation.

Answer piping

Insert previous answers into upcoming questions or fields.

Pre-fill fields

Pre-populate fields based on previous inputs and more.

Integration logic

Perform an integration only when a certain condition is met.