Calculations Overview

The Rulestar platform contains a powerful custom-made calculation engine that can perform a wide range of useful and complex calculations. Every field type can be used in some form of calculation, although the main fields will be number and date/time fields. You can also include literal values (eg, "5" or "21") in calculations alongside fields.

In the event of syntax or other calculation errors, the calculation engine will provide helpful feedback as to the location and description of the error.


Setting up a calculation

Calculations within the Rulestar system can be performed within a number, date/time or text field. To decide which type of field you require for the calculation you want to perform, consider the output (or result) of the calculation.

If the output is a:

  1. number (eg, 100) use a number field,
  2. date (eg, 01/01/2000) use a date/time field, and
  3. string (eg, "Hello World") use a text field.

Preparing a field for calculation is easy - simply follow these steps:

  1. navigate to the location in the form builder where you want to perform the calculation. If a calculation uses other fields, make sure these other fields are above the new field,
  2. select "New Field" and select either a number, date/time or text field depending on your requirements,
  3. give the field a label, and
  4. set the field as either "Read Only" or "Hidden" (based on if you do or don't want to see the field in the smart online form).

The field is now set up to perform calculations. Navigate to the "Calculation" tab to enter the calculation expression. Fields can be added to the calculation expression by selecting them in the "Reference Field" dropdown or by copying and pasting the field reference code (see both methods below). You can also construct all calculations using the calculation helper.

Calculation helper

The calculation helper can be used to easily add calculation methods and field properties to your forms. To start using the calculation helper, navigate to a field's "Calculation" tab and click "Start Here". The expanded helper includes a dropdown list of all methods (sorted into specific categories eg, "date" or "string"). After selecting the desired calculation, the helper prompts you to add the required fields and provides useful hints as to the valid input types as well as instant input validation. Fields can be added to the calculation by inserting them from the "Reference Field" or by copy and paste.


Calculation operators

Rulestar's custom calculation engine supports a range of operations and functions to assist you in performing a variety of useful calculations. Operations available include:

  • addition, subtraction, multiplication and division,
  • relational and equality comparisons eg, "greater than" and "equal to",
  • the logic operators "and", "or" and "not", and
  •  the conditional operation; "if, then, else".

To find out more about these operators, click here.


Date calculations

Rulestar's calculation engine supports a range of date calculations. You can:

  • calculate the duration between two dates,
  • compare the order of two dates, and
  • add or subtract a duration of time to a particular date.

To find out more about date calculations, please click here.


Calculations using options

Fields with options (checkbox, radio and select fields) can be used in calculations when they have numeric option values. Click here to find out more about using fields with options in calculations.

String calculations

String calculations include methods for string querying and manipulation, as well as string concatenation. You will find a use for string calculations in creating customised input validation and highly tailored field labels and rich text field guidance

To find out more about string calculations, click here.


Min and Max functions

There are two additional functions in the Rulestar system. They are:

  • Min(A, B) - returns the minimum of A and B, and
  • Max(A, B) - returns the maximum of A and B.

Both functions require two or more numeric or date/time arguments (all arguments must be the same type, all numbers or all date/times).

Repeatable section calculations

There are two categories of repeatable section calculations:

  1. The first category can be thought of as the "properties" of the repeatable section, such as the total number of repetitions and the 'current' repetition. To find out more about these calculations, click here.
  2. The second category of repeatable section calculations are "field-level" calculations. Currently, the only field-level calculation is the "RepeatSum" property.


The "RepeatSum" property is a shortcut to return the sum of all of the repetitions of a number field within a repeatable section. For example, rather than building the calculation:

Cost of Item #1 + Cost of Item #2 + Cost of Item #3 etc...

where each input is a repetition in of a repeatable section, you could use:

Cost of Item #.RepeatSum

This calculation will automatically sum up each repetition of "Cost of Item".