Other articles in this category
Search More Content
Using Calculations with Number form fields
When using a Number field with calculation enabled or a Product field set to Calculation type, you are able to easily perform calculations. In this article, we will show you how to set up a calculation in a Number field.
Note: The Total field type cannot be used within calculations. Within this article, only Number fields are used.
This article assumes that you are already located within the form editor. If not, access it by clicking on Forms, then on your desired form.
- 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.
- 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.
- 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 calculation.
Decimal dot format: Number format where a dot is used as a 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 typed by you manually in the formula, must be entered in decimal dot format and use the full number. Example: 0.2 is valid, .2 is not valid.
- When filling out number fields on the front end of the site, users must use the format configured for that number field, regardless if that field is being used on a calculation using a different number format.
- When using a drop down or checkboxes field types in a formula, the values must be formatted with the same format as the field containing the formula.
For example, you have a calculated number field formatted with a decimal comma (i.e. 9.999,99). If this number field has a calculation formula that references a drop down field, the values of the drop down field must also be formatted with decimal commas.
- 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 values that aren’t whole numbers (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 must be positioned before the calculation field, and not hidden by logic. This is because calculations are rerun during submission using saved values and if the field hasn’t been saved yet or ignored by logic at form submission it won’t have a value available so your result will be incorrect or empty.