Using Calculations

Introduction

Calculations are available within a field when using a Number field with calculation enabled or a Product field set to the Field Type of Calculation. In this article, we will show you how to set up a calculation in a Number field, as well as go over some important rules on using number fields in calculations as well as the rules supporting different decimal formats.

Supported field types: text, number, drop down, checkbox, radio, hidden, single product, price, hidden product, calculation, and single shipping.

Note: The Total field type cannot be used within calculations. Within this article, only Number fields are used.

You perform all the following steps from within the Form Editor.

Creating a calculation formula

We will generate a simple example of a calculation using two Number fields. 

  1. Add 2 different number fields and name them First Number and Second Number.
  2. Save your form, it is important to do this so the newly added fields are available when setting up the calculation formula in later steps.
  3. Add a third Number field which will handle the result of the calculation. Name it Total.  Ensure that this field is positioned after the first two Number fields.
  4. Access the field settings of the Total field.
  5. Select the Enable Calculation checkbox to enable this field to be populated based on a calculation result. Once the Enable Calculation checkbox is selected, additional options will appear below it. See image (A) below.
  6. Access the field settings of the Total field. Click the button Insert Merge Tag and select your first field in the calculation. Note that only fields valid for use in calculations will be listed. See image (B) below.
  7. Add a mathematical operator. In this case, simple addition (+).
  8. Insert the Second Number field to complete the calculation.
  9. Check the calculation by clicking Validate Formula. If it says that your calculation is invalid, go back and take another look. See image (C) below.
  10. Your calculation is all set. Be sure you Save your form.
Screenshot of Number Field Settings
(A) Enabling calculations within your Number field titled “Total”.
 Screenshot of Calculation Merge Tags
(B) Using the merge tag selector to insert your operands.
Screenshot of Final Calculation
(C) Final formula

Number Formatting Rules

This section explains how to format numbers properly for product pricing and calculations.

Terminology

Decimal dot format: Number format where a dot is used as the decimal separator. Example: 5.20
Decimal comma format: Number format where a comma is used as a decimal separator. Example: 5,20

Rules

  • When creating a calculation formula, all numbers manually entered in the formula must:
    • Be entered in decimal dot format**, and
    • Use a preceding 0 if required. Example: 0.2 is valid, 0,2 is not valid, .2 is not valid.
  • When entering number fields on a form on the front end of the site, users must enter the format configured for that number field, even if that field is being used in a calculation that uses a different number format.
  • When using drop down or checkbox field types in a formula, the values must be formatted with the same format as the field containing the formula.
    For example, if you have a calculated number field in decimal comma format (i.e. 9.999,99) that has calculation formula that references a drop down field, the values of the drop down field must also be in decimal comma format.
  • If the number field is configured with a “Currency” Number Format, the drop down values must be formatted with the same decimal separator as the currency.
  • When using a quantity drop down field to specify fractional values (i.e. 5.5), those numbers must be formatted with the same decimal separator as the site’s currency.
  • ​​​​​​Fields referenced in a calculation formula (1) must be positioned before the calculation field, and (2) must not be hidden by logic. This is because calculations are rerun during submission using saved values, and if the field hasn’t been saved yet or has been ignored due to logic at form submission, it won’t have a value available for the calculation, leaving the result either incorrect or empty.

Limitations

  • Certain special field types, like Survey, Quiz, Polls, or Coupons fields, are not supported for calculations.
  • Total type fields are always the last to be saved, so they can’t be used in calculations.

Incorrect Entry Result

Please see the Troubleshooting Issues with Calculation Results article.