Computing Formulas in the Data Manager

The main data pane in the Data Manager task includes a formula bar, where you can define attributes by using columns, constants or functions in formulas.

The formula bar is divided into two distinct parts:

  • left-hand side member: corresponds to the attribute which will be defined by the formula. 

  • right-hand side member: contains the formula to define the new attribute.

Values can be entered manually, selected from the corresponding drop-down list or inserted by clicking on a cell in the spreadsheet. When you click on a cell in the spreadsheet, the corresponding attribute is added in the formula, with the format $"attribute_name". Functions and operators can also be used to define the formula.

Process variables can also be used in formulas. They are recognized by the "@" prefix. For example, @Today could be a process variable that contains the current date. For more information on process variables see Using Process Variables in Rulex.

Copying & pasting formulas

Formulas can be copied and pasted from a column to another, by right-clicking the column header and selecting Copy Formula. Then you select the target columns, right click and select Paste Formula. The attributes in the formula are automatically "shifted".

For example, if new_attribute_1 is defined $"new_attribute_1" = $"attribute_name_1"+1 and we copy and paste this formula into new_attribute_2 (where new_attribute_2 is the attribute immediately after new_attribute_1 in the attribute list) then the pasted formula will be $"new_attribute_2" = $"attribute_name_2"+1 where attribute_name_2 is the attribute immediately after attribute_name_1 in the attribute list.

If you don't want the attributes to be "shifted" you can just put an extra '$' before the attribute name. For example, if you copy the formula $"new_attribute_1" = $$"attribute_name_1"+1, then the pasted formula in new_attribute_2 will be $"new_attribute_2" = $$"attribute_name_1"+1. Of course, in a single formula you can insert both attributes with a single '$' and attributes with a double '$'.

Shortcuts for inserting formulas

  • if the left-hand side member was entered manually, jump to the right-hand side member by pressing Tab

  • if the left-hand side member was inserted by clicking on a cell in the spreadsheet, jump to the right-hand side member by pressing ‘=

Procedure

  1. In the formula bar, in the left-hand side member, enter the attribute you will be defining in one of the following ways:

    • manually enter the attribute using the syntax $”attribute_name”

    • select an existing attribute from a drop-down menu

    • click on a cell in the spreadsheet.

  2. Click the function button and select the function required to create the formula. For a list of functions provided by Rulex, see Rulex Language Functions

  3. In the right-hand side member, create the formula which will define the attribute by:

    • entering attributes

    • entering constants.

  4. Press enter or click on the apply button.

Selecting multiple attributes

  • If you need to select more than one attribute at a time, you can use either press Ctrl and select all the required attributes: ($"att1", $"att5", $"att11")

  • If you need to select a range of attributes, you can either press Shift and select the first and last attribute in the range, or select them all with the cursor. The formula bar will include a colon to indicate the range: $"att1":$"att5"

Examples of multiple selection syntax:

  • $"att_sum" = sum($"att1",$"att5", $"att11")

  • $"att_sum" = sum($"att1":$"att5")