Start free trial

Calculation field

The Calculation Field lets you easily automate form calculations and is great for anywhere you might need to compute a value based on what users select on your form.

Quickly process online bookings, product orders, medical assessments and scores, event registrations, monetary donations, expense reimbursements, employee surveys, and more.

1. Set up your basic form first

To get started you should build your form containing all the relevant fields that will make up the calculation. If this is your first time building a form, please check our form building resources or watch the getting started video to get your form set up first.

In the below example we’ve added fields to our form asking the user to select the product size, as well as the quantity. We’ll be using these in our calculation formula.

2. Assign numeric values to answers where needed

We expect people to enter a number in to the ‘How many products would you like?’ field so we don’t need to do anything else on that one.
However since the ‘Product Size’ field is a choice of text answers, we need to assign numeric values to each of the answers (Small, Medium or Large).
Numeric answers must be assigned to values for all of the following field types:

  • ‘Choose one’ fields
  • ‘Choose multiple’ fields
  • ‘Drop down list’ fields
  • ‘Choice Matrix’ fields

To assign numeric values for these fields, edit the relevant field:

Then click ‘Show Advanced Options’:

Then assign a numeric value for each of the Choices for that field. Put the numeric values in the same order as the Choices.
In the below example we’ve set Small to 10, Medium to 20, and Large to 30.
Then save the field.

3. Add the calculation field and set up the formula

Now that you’ve set up your initial form fields and assigned numeric values where needed, you can add the calculation field and formula.

Start by dragging a ‘Calculation’ field type in to your form.

In the calculation field settings give your calculation field a name. In our example we’ve called it ‘Total price’.
Then build your formula by selecting the fields in the right hand drop down box. As you select each field it will be added to the formula on the left.
In our example we inserted the product quantity question, then typed a * symbol for multiplication and then inserted the product size question.
The quantity multiplied by the cost of the selected product size will give us the total price.

Note: You’ll see above that each of your form fields is listed twice in the field choice drop down when inserting in to a formula.
If a specific question is not mandatory or critical to your formula, and you’re happy for the calculation to be done before or without an answer being provided for that specific question, then select the ‘AS OPTIONAL VALUE’ version.

You can also type or insert mathematical symbols in to the formula box such as:

  • + for addition
  • – for subtraction
  • * for multiplication
  • / for division
  • ( ) brackets for building multiple nested formulas in one


Note: Please see Section 4 and Section 5 below for Formula Examples and Operators.

After building the formula we have a few extra optional settings in the calculation field as shown in the below screenshot.

  1. Decimal places – determines the number of decimal places the result will have.
  2. Placeholder – an optional description that will appear inside the calculation field before the calculation is done.
  3. Value prefix – an optional prefix that will appear below the final calculated value. For example a $ or other currency symbol.
  4. Value suffix – an optional suffix that will appear after the final calculated value. For example ‘ per month’ or ‘ dollars’.
  5. Read only – tick if the calculation value should be ‘read-only’ on the form which means the user filling in the form cannot change it.
  6. Hidden – tick if the calculation field should be hidden on the form, and only visible to you when you receive the submission.

 

4. Using operators to build your formula

You may use operators for all common arithmetic operations and conditional expressions. The following operators are available with examples of their use.

OperatorNameExample Formulas
+Add{{product price}} + {{fee}}
Subtract{{hours worked}} – {{breaks}}
*Multiply{{quantity}} * {{product price}}
/Divide{{people}} / {{tables}}
^Power{{interest}} ^ {{percentage}}
? :Conditional expression{{age}} == 18 ? “you are 18” : “you are not 18”
==Equal{{age}} == 18 ? “you are 18” : “you are not 18”
!=Unequal{{age}} != 18 ? “you are not 18” : “you are 18”
<Smaller{{score}} < 10 ? “Low” : “High”
>Larger{{score}} > 10 ? “High” : “Low”
<=Smaller or equal to{{hours}} <= 7 ? “you have 7 hours or less” : “you have more than 7 hours”
>=Larger or equal to{{hours}} >= 7 ? “you have at least 7 hours” : “you have less than 7 hours”
to, inUnit conversion{{minutes}} minutes to seconds
{{hours}} hours to minutes
{{seconds}} seconds to years
{{length}} cm to meters
andLogical and{{age}} > 18 and {{age}} < 65 ? “Adult” : “Other”
orLogical or{{priority}} == 1 OR {{priority}} == 2 ? “High” : “Low”
( )Grouping{{hours}} * ( {{minutes}} / 60 )

 

5. Formula Examples – Q & A

Here are some more advanced formula building scenarios to help you get started.

Q: Require or don’t require all questions to be answered before the formula will calculate.
A: While inserting field values in to your formula you have the option of choosing the ‘As optional value’ version of each question. If you choose the ‘As optional value’ version the formula will calculate with or without the user selecting an answer for that field.

Q: Using IF statements within calculations
A: You can use IF statements within your formula to determine outcomes based on multiple scenarios.
The format for an IF statement is:
CONDITION ? RESULT IF TRUE : RESULT IF FALSE

The below example shows an IF statement in action where the result is text. As the result is in text we have surrounded it with quotation marks ”
The below formula depicts: “IF the product has a value of 1, THEN the result is “sales@acme.com”, ELSE the result is “support@acme.co”

Q: Using multiple IF/ELSE IF scenarios
A: There are times when you may need to calculate a result based on multiple IF ELSE IF scenarios.
The format for chaining multiple if / else if statements is:
CONDITION ? RESULT IF TRUE : NEXT CONDITION ? RESULT IF TRUE : NEXT CONDITION ? RESULT IF TRUE : RESULT IF FALSE

The below example shows an IF / ELSE IF statement with multiple scenarios resulting in different text results.
The below formula depicts: “IF age is less than 12, THEN the result is “you are a child”, ELSE IF age is less than 18, THEN the result is “you are a teenager”, ELSE IF age is less than 65, THEN the result is “you are an adult”, ELSE the result is “you are an older adult”.

Q: Nested formulas
A: You can use brackets to nest formulas within formulas.
The below formula depicts: “IF the product chosen has a value of 1, THEN the result should be the Quantity times 5, otherwise the result should be the Quantity times 10.”

Q: Calculating the time between two dates
A: You can calculate the time between two ‘date’ fields by inserting the date fields in to your formula as normal.
The result will be in seconds, so you need to divide it if you want minutes, days, years or something else.
The below example gets the minutes between two dates.


Q: Calculating between a specified date and the current date
A: To calculate the time between a specified date and the current date you can insert the ‘Current date & time’ field from the field drop down.
The result will be in seconds, so you need to divide it if you want minutes, days, years or something else.
The below example will give the number of days between the selected date and the current date.

Get an online form trial or demo absolutely free.