How to Use the Formula field (PRO account)

The Formula field is a hidden field that is not displayed on the published form. The field allows you to set up formulas and calculate a value using data that your respondents enter into different fields on your form. To display the result of the calculation, you need to use the piping functionality (@) in the Text form fields. One form can have multiple Formula fields.

The Formula field allows you to:

  1. Perform mathematical calculations according to the set formula.
  2. Format the calculation result, using the functions from the Math.js library, for example, rounding numbers, etc.
  3. Create multi-statement calculations.
  4. Make conditional calculations.

How to set up the Formula field and display the calculation result.

  1. Add the Formula form element to any part of your created form.
  2. Enter the field name.
  3. Enter your desired formula. To use the data from your form fields, use the @ function to reference the fields in the formula.
  4. Add the Text field to your form. Type in the text you would like to display for your respondents and use the @ function to reference the Formula field result.

Example: your form calculates a room area using the data it collects from two form fields: Width, m and Length, m

The screenshot below illustrates the Area Calculator setup.

How to Use the Formula field

How to round your Formula field result:

The round function allows you to round your formula result with specified precision — zero, one, two, etc. decimals displayed.

For example, you are going to add numbers from two form fields and round the result of the calculation:

Example 1: round(@field1 + @field2, 3) This will return the result with three decimals.

Example 2: round(@field1 + @field2, 0) This will return the result with zero decimals.

The ´round´ function is just one of the functions from the Math.js library that is supported by AidaForm. To review the full list, please visit https://mathjs.org/docs/reference/functions.html

How to make multi-statement calculations

Sometimes you may want to split your formula into several lines (separate statements or calculations) to make it easier to work with.

Important: Use semicolons to separate statements!!!

Example: to calculate the Net Promoter Score, we decided 1) to replace the long field labels employed in the formula with assignments and 2) to split the formula calculations into several parts.

As a result, the calculations become easier to read and manage:

How to Use the Formula field

How to make conditional calculations

Sometimes your formula may depend on the conditions laid upon the data entered by your respondent. For such cases, you may set up calculations with conditions.

For example, you would like to create a Cleaning Services Price Calculator and your prices depend on the area in sq.m of the house that needs cleaning:

1 - 20 m²: $20/m²
20 - 80 m² $15/m²
80 m² and higher: $10/m²

Here you may use a ternary operator in the form of Condition ? A : B , which will evaluate to A if the Condition is true and B otherwise.

Your formula field calculations may look like this:

How to Use the Formula field

Or like this:

How to Use the Formula field

To review the full list of available operators, please visit https://mathjs.org/docs/expressions/syntax.html

Sample forms with Formula fields to add to your PRO account and review settings:

For your convenience, we have created several examples of the calculators that you can add to your AidaForm PRO account to review all settings and edit to adjust them to your needs.

  1. NPS Calculator

    The calculator employs multi-statement calculations, the round function and logic jumps to direct users to different calculator pages depending on the resulting score.

    Use the link to add NPS Calculator to your AidaForm account.

  2. BMI Calculator

    The calculator employs multi-statement calculations and the round function.

    Use the link to add the BMI Calculator to your AidaForm account.

  3. Cleaning Service Price Calculator

    The calculator employs multi-statement calculations, conditional calculations and includes an order page to generate orders for calculated cleaning services.

    Use a similar calculator to collect contacts and generate leads.

    Use the link to add the Cleaning Service Price Calculator to your AidaForm account.

Request a Form for Free