# 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 formulas in one

Note: Please see ‘Section 4: Advanced Formulas’ below for more information on formula building.

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

- 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 that will appear below the final calculated value. For example a $ or other currency symbol.
- Value suffix – an optional suffix that will appear after the final calculated value. For example ‘ per month’ or ‘ dollars’.
- 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.
- Hidden – tick if the calculation field should be hidden on the form, and only visible to you when you receive the submission.

**4. Advanced Formulas – 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 ”

**Q: Nested formulas or IF statements **A: You can use brackets to nest formulas within formulas or formulas within IF statements.

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.