Calculations and variables
Calculate prices for order forms, compute the score of a quiz, and much more with your Fillout forms. Dynamic variables let you do math and logic in your form, fully responsive to respondent input.
Video tutorial
Add a calculation
Open the
Logic
modal in the bottom-right of your form editor.Click
Calculations
followed by + New calculation
. Here, you’ll be able to add, edit, and delete calculations in your form. Add your calculation by giving it a Name and Type.
The name refers to how you’ll refer to it in-app, whereas the type can either be one of these:
- Number - if you want to compute some numerical result, like a price or a score
- Text - if you want to compute some dynamic text, e.g. some text that depends on a user’s selections in the form.
- Duration - if you want to compute the interval between two dates, e.g. age or term period
How to configure a calculation
Provide an Initial value for your calculation.
Every calculation has some value that it starts with, e.g. defining what a variable starts out as. Some common examples:
- 0 - if you want to add to a price variable over time as the respondent picks options
- 100 - if you want to deduct points for wrong answers on a quiz from 100
- Any arbitrary text - for a text calculation (or leaving it empty)
Define Rules for how the value of your calculation changes.
A rule is made up of 3 main parts:
- Operation - this is what you want to do to your calculation, e.g. Add a number to it
- Operation value - this is the value that interacts with the operation, e.g. Add whatever number you provide
- Condition - this defines when you should perform that operation. This is similar to how you might hide/show a question depending on user input
You can drag and drop conditions using the handle on the right-hand side to re-order them. Rules will take effect in the order that they appear on this screen. For example, you can add 5, and then multiply by 2, instead of doing it vice versa.
Common ways to use your calculations effectively
Set the price for your Payment page
After adding a payment page, type
@
or click the +
icon to reference a calculation instead of a static price for your payment page.
Now, the price will change depending on the customer’s order.
Display the calculation in your form
Anywhere in Fillout, you can type
@
to reference previous answers or calculations. You can style this text by highlighting it and changing the font size, weight, or color.Determine age, trip duration, warranty validity, and more
When making a new calculation, choose
duration
as the type. Select Start and End dates in your calculation followed by the measurement for Units.Pre-fill fields with a calculation
Much like how fields are pre-filled elsewhere in Fillout, you can reference calculations there as well.