1. Help
  2. Features
  3. Math calculations

Math Calculations

Math calculations allow you to create calculated fields in your forms by using field inputs as variables. This is specially useful for creating quotation forms , payment forms , tax calculators, loan calculators, and much more.

Math calculations build on top of field references.

Basic usage

Math calculations can be used in all places where field references can be used. This includes, but is not limited to:

  1. The content of rich text fields
  2. The value of hidden fields
  3. Labels and descriptions of fields
  4. The recipient, name, reply-to, subject, and content of email workflows
  5. The content of success messages
  6. Field mapping in workflows

Math calculations are denoted using curly braces {}. Inside the curly braces you can use field references and basic math operators.

Fields are referenced using their ID. You can find the ID of a field on the top-left corner of the field settings dialog (which is accessed using the cog icon).

Finding the field ID
Finding the field ID

The field ID for the Number A field is field1. Field IDs are unique and always start with field.

In this example, let us say we wanted to show the sum of the Number A and Number B fields in the rich text field below. To do so we would use this formula in the content of the rich text field:

{ field1 + field2 }

Using math calculations to add two numbers in a form
Using math calculations to add two numbers

The results of math calculations are updated in real-time as the input changes.

Operators and variables

As we have seen above we can use fields as variables in our math calculations.

We can also use the following operators:

+, -, *, /, ^, (, )

Apart from this we can also use regular numbers as constants in our calculations, example:

{ 100 + ( field1 * 2 ) + ( field2 * 5 ) }

Functions

You can also use built-in functions to perform more complex calculations. The following functions are supported:

Max

Returns the larger number of the given two numbers.

{ MAX(field1, field2) }

Min

Returns the smaller number of the given two numbers.

{ MIN(field1, field2) }

Format

Formats a number to include commas and decimals, based on the browser locale.

{ FORMAT(field1) }

So a number like 1234567.89 would be formatted as 1,234,567.89 in the US, and 1.234.567,89 in Germany.

Round

Rounds a number to a certain number of decimal places.

{ ROUND(field1, 2) }

So a number like 1234.56789 would be rounded to 1234.57 if the second argument is 2.

Sqrt

Returns the square root of a number.

{ SQRT(field1) }

If

Returns one value if the condition is true, and another value if the condition is false.

{ IF(field1, field2, field3) }

So if field1 is 1, the result would be field2, otherwise it would be field3.

Note that the condition is evaluated as false if the number is 0, or if the field is empty. Otherwise it is considered true.

Currency

Formats a number based on the specified currency code.

{ CURRENCY(field1, USD) }

Left

Returns the left part of a string, up to the specified number of characters.

{ LEFT(field1, 5) }

Right

Returns the right part of a string, up to the specified number of characters.

{ RIGHT(field1, 5) }

Mid

Returns the middle part of a string, starting from the specified position, up to the specified number of characters.

{ MID(field1, 5, 10) }

Upper

Converts a string to uppercase.

{ UPPER(field1) }

Lower

Converts a string to lowercase.

{ LOWER(field1) }

Examples

Here are some practical examples:

Adding two fields

{ field1 + field2 }

This adds the values of field1 and field2.

Multiplying a field value by a constant

{ field3 * 10 }

This multiplies the value of field3 by 10.

Using parentheses for order of operations

{ (field4 + field5) * field6 }

This adds field4 and field5, then multiplies the result with field6.

Combining functions and operators

{ MAX(field7, field8) + MIN(field9, field10) }

This calculates the maximum of field7 and field8, adds it to the minimum of field9 and field10.

Nested functions

{ ROUND(SQRT(field11), 2) }

This calculates the square root of field11 and then rounds it to 2 decimal places.

Notes

Datepicker field

When a date field is referenced in a formula, the value used is the number of days since today. So if the date is in the future, the value will be positive, and if the date is in the past, the value will be negative.

Example, if the form is being filled out on January 10th, 2021, and the date field is set to January 15th, 2021, the value used in the formula will be 5.

If we have a formula like this: { field1 * 10 }, the result would be 50.

Tabular fields

This field is not supported in math calculations.