Rules for Calculations

What Are Rules For Calculations?

When specifying a calculation in a field, there are several formatting and order of operation rules to be aware of to ensure you obtain the expected result. These rules can apply to adding calculations for number fields or pricing calculations. A collection of these rules have been collated into this article.

Number Formats

This article refers to the number formats decimal dot and decimal comma. Decimal dot is when a number is formatted to use a dot (period) as the decimal separator, and a comma is sometimes used as a thousand separator.

FormatDescription
Decimal dot3.142 or 1,234,567.89.
Decimal comma3,142 or 12.345.678,9

Rules For Field Order

Note: Calculations are rerun during submission using saved values. 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, empty, or zero.

CategoryRule
Field OrderIt must be positioned in the form before the calculation field
Field OrderThe field cannot be hidden by logic.

Examples

If you have three Number fields defined on your form as follows:
Field 01 has no calculation
Field 02 calculation is Field 01 * 2
Field 03 calculation is Field 02 * 3

Putting them on your form in order:
Field 01
Field 02
Field 03

would work as expected.

But putting them on your form in order:
Field 03
Field 01
Field 02

would produce unexpected results for Field 03. This field would be undefined at calculation time and likely saved to the entry as a 0.

Rules for Entering Numbers

Decimal Dot Format

CategoryRule
Entering NumbersWhen creating or editing a calculation formula in the Form Editor, any number entered directly in the formula must be entered in decimal dot format. You cannot include a thousand separator positioned in the form before the calculation field.

Examples

1.2 works, but 1,23 or 1,234 or 1,234.56 do not. This rule applies even if your site’s native number format is set to decimal comma format.

Preceding Zero

CategoryRule
Entering NumbersWhen creating or editing a calculation formula in the Form Editor, any number entered directly in the formula must use a preceding 0 if the first digit is a dot.

Examples

0.2 is a valid number for use in a calculation. .2 and 0,2 are not.

Rules for other fields included in a calculation

CategoryRule
Other FieldsWhen creating a formula that refers to a field of type Drop Down or Checkbox, the values defined in those fields must use the same format as the field that contains the formula.
Other FieldsIf 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.
Other FieldsWhen using a Quantity field configured as a drop-down, any fractional values (such as 5.5) on the drop-down must be formatted with the same decimal separator as the website currency.

Examples

If you have a calculated number field in decimal comma format (i.e., 1.234,56) that references a Drop Down field in its calculation, the values of the Drop Down field must also be in decimal comma format.

Rules For Not Supported Fields

Some field types are not supported for calculation use, even though they may produce numeric output. They include:

Rules For Field Validation

CategoryRule
Field ValidationWhen a user enters data into a number field on a form, they must enter the format configured for that field to pass validation, even if that field is used in a calculation using a different number format.