Calculation field

The Calculation field lets you automate form calculations and is helpful anywhere you might need to compute a value based on what users select on your form.

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

Set up your basic form first

To start, you should build your form containing all the relevant fields to 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 this example, we’ve added fields to our form asking the user to select the product size and quantity.

We’ll be using these in our calculation formula.

Assign numeric values to answers where needed

We expect people to enter a number into the 'How many products would you like?' field, so you do not need to do anything else.

However, since the 'Product Size' field is a choice of text answers, we must assign numeric values to each answer (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;

  1. Click the Edit Field Details button.

  2. Click 'Show Advanced Options'.

  3. Assign a numeric value for each of the choices for that field.

Put the numeric values in the same order as the Choices.

  1. Click Save.

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 into 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, 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.

You will see that all of your form fields are listed twice in the field choice drop-down when inserting into 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 into the formula box, such as:

  • + for addition.

  • - for subtraction.

  • * for multiplication.

  • / for division.

  • ( ) brackets for building multiple nested formulas in one.

Read the Using operators to build your formula and Formula examples sections for examples and operators.

After building the formula, we have additional optional settings in the calculation field.

Decimal places

Determines the number of decimal places the result will have.

Placeholder

An optional description that will appear inside the calculation field before the calculation is done.

Value prefix

An optional prefix appearing below the final calculated value. For example, a $ or other currency symbol.

Value suffix

An optional suffix appearing after the final calculated value. For example, 'per month' or 'dollars'.

Read only

Select if the calculation value should be 'read-only' on the form, which means the user filling in the form cannot change it.

Hidden

Select if the calculation field should be hidden on the form and only visible when you receive the submission.

Using operators to build your formula

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

Operator Name Example 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}} <= seven ? "you have seven hours or less" : "You have more than seven hours."

>=

Larger or equal to

{{hours}} >= seven ? "you have at least seven hours" : "You have less than seven hours."

to, in

Unit conversion

{{minutes}} minutes to seconds {{hours}} hours to minutes {{seconds}} seconds to years {{length}} cm to meters

and

Logical and

{{age}} > 18 and {{age}} < 65 ? "Adult" : "Other"

or

Logical or

{{priority}} == one OR {{priority}} == two ? "High" : "Low"

( )

Grouping

{{hours}} * ({{minutes}} / 60)

Formula examples

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

  1. Require or do not require all questions to be answered before the formula will calculate.

    While inserting field values into your formula, you can choose 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.

  2. Using IF statements within calculations

    You can use IF statements within your formula to determine outcomes based on multiple scenarios. The format for an IF statement is as follows:

    CONDITION ? RESULT IF TRUE : RESULT IF FALSE

    This example shows an IF statement in action where the result is text. As the result is text, we have surrounded it with quotation marks ".

    The below formula depicts the following scenario: *IF* the product has a value of 1, THEN the result is "sales@acme.com", ELSE the result is "support@acme.co"

  3. Using multiple IF/ELSE IF scenarios

    Sometimes, you may need to calculate a result based on multiple IF/ELSE/IF scenarios. The format for chaining multiple IF/ELSE/IF statements is as follows:

    CONDITION ? RESULT IF TRUE : NEXT CONDITION ? RESULT IF TRUE : NEXT CONDITION ? RESULT IF TRUE : RESULT IF FALSE

    This example shows an IF / ELSE IF statement with multiple scenarios resulting in different text results.

    The below formula for the following scenario: *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".

  4. Nested formulas

    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.

  5. Calculating the time between two dates

    As usual, you can calculate the time between two date fields by inserting the date fields into your formula. The result will be in seconds, so you need to divide it if you want minutes, days, years, or something else.

    This example gets the minutes between two dates.

  6. Calculating between a specified date and the current date

    You can insert the Current date & time field from the field drop-down to calculate the time between a specified date and the current date.

    The result will be in seconds, so you need to divide it if you want minutes, days, years, or something else. This example will show the days between the selected and current dates.