Calculations are available within a field when using a Number field with calculation enabled, or a Product field set to 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.
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
- First, you will need to add your Number fields. In this example, we will add 2 different number fields and name them First Number and Second Number.
- 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.
- Next, a third Number field will be added which will handle the result of the calculation. For this example, we will name it Total.
- Within the Result field access the field settings by clicking on the field. Inside the field settings, you will notice a checkbox labeled Enable Calculation. Select this box to enable this field to be populated based on a calculation result.
Note: Ensure that this field is positioned after the Number fields that are being used as the basis for the calculation. If reversed, the calculation will not work correctly.
- Once the Enable Calculation checkbox is selected, additional options will appear below it. This is where you will configure the fields to be calculated. You’ll need to add the first field to be calculated. To do so, click on the dropdown labeled Insert Merge Tag,then and select your first field in the calculation. Note that only fields listed on the dropdown are supported for calculations, if a field is not listed, don’t try to insert its merge tag manually because it will not work.
- Then, based on how you want to calculate this field, use the symbol buttons to the right of the drop down to add, subtract, multiply, divide, etc. your second field.
- Of course, you will now need to add your next field. Jump back to the drop down and click on the next field in your calculation.
- Now that your calculation is all set up, check it by clicking Validate Formula. If it says that your calculation is invalid, go back and take another look.
Your calculation is all set. Be sure to save your form settings to ensure the field settings are valid.
Number Formatting Rules
This section explains how to format numbers properly for product pricing and calculations.
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
- When creating a calculation formula, all numbers manually entered in the formula must: (1) be entered in decimal dot format**, and (2) 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 be 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.