Calculated Fields – WS Form

Calculated FieldsPRO

The calculated fields function in WS Form PRO makes it easy to create calculate field values that are updated in realtime. It can handle everything from simple addition to more complex trigonometric functions.



How To Create A Calculated Field

Common field types you might use a calculated field in include:

You can put calculated values in the default value of the field as well as the label, placeholder or help settings if available.

To create a calculated field value for the default value of a field, click the field settings icon and then enter a #calc(...) variable in the ‘Default Value’ setting.

WS Form - Calculated Field Values - Default Value Setting

Anything within the brackets will be calculated in realtime on your form and used as the value of your field.

You can create calculations such as:

#calc(1 + 2)

You can include values from other fields on your form, for example, multiplying field ID 123 value by 5:

#calc(#field(123) * 5)

You can use WS Form math variables (listed at the end of this document) to perform more complex calculations, for example, rounding the previous example to two decimal places:

#calc(#round(#field(123) * 5, 2))

You could even create a calculated field that works out the sum of all values of a field in a repeatable section. The syntax is easy:


… where field ID 123 is a field in a repeatable section. WS Form PRO automatically sums the values together.  The #section_row_count(456) function (where 456 is the section ID) can be used to calculate the average value of those values:

#calc(#field(123) / #section_row_count(456))

There is an easier way of creating these calculations … the calculator!


WS Form PRO includes a calculator feature that helps creating calculated values for fields.

  1. Click the field settings icon.
  2. Click the calculator icon. On most fields this is found on the ‘Default Value’ setting.

The calculator will then appear directly below:

WS Form PRO - Calculated Fields - Calculator

The cursor will automatically position itself within the #calc() function. In addition to the normal numeric and arithmetic buttons, the calculator has the following additional buttons:

Insert Field – Click this to insert a #field() variable into your calculated field. It lists all of the fields on your form that are compatible with the calculated field feature.

del – Deletes a character

AC (All Clear) – Deletes the entire calculation

f – Inserts a math variable into your calculation such as #pi, #cos(...) or #sin(...) (See below)

Note that whilst the calculator will do its best to maintain a suitable cursor position, you can always click on the default value itself to reposition the cursor.


In addition to #field(...), the following variables can be used inside with #calc(...).

Name / VariableAdditional Information
Returns the absolute value of a number.
Returns the average of all the input numbers.
Base to the Exponent Power
#pow(base, exponent)
Returns the base to the exponent power.
Rounds a number up to the next largest whole number.
Returns the cosine of a radian number.
Returns E to the power of a number.
Returns the largest integer value that is less than or equal to a number.
Returns the natural logarithm of a number.
Returns an approximate value of PI.
#round(number, decimals)
Returns the rounded value of a number.
Returns the sine of a radian number.
Square Root
Returns the square root of the number.
Returns the tangent of a radian number.
Name / VariableAdditional Information
Seconds in a day
Returns the number of seconds in a day.
Seconds in a minute
Returns the number of seconds in a minute.
Seconds in a week
Returns the number of seconds in a week.
Seconds in a year
Returns the number of seconds in a year.
Seconds in an hour
Returns the number of seconds in an hour.
Seconds since Epoch
Returns the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
Name / VariableAdditional Information
Random Number
#random_number(min, max)
Outputs an integer between the specified minimum and maximum attributes. This function does not generate cryptographically secure values, and should not be used for cryptographic purposes.