Common Operators in Data Manager Formulas

The following common operators are supported in Rulex formulas:

Operator Symbol

Function

Examples

“ “

String delimiter.

Strings are always enclosed in quotation marks, and can contain any characters.

Sales Trend”, “This is a complicated \t string $5%msd\n

@

Prefix to process variables.

Variables can only contain letters (capital and small), numbers and underscore.

@threshold_today

$

Identifies a column/attribute in a dataset

shift($"Weekly_Sales",1,$"Store")

( )

List parenthesis. Brackets can be used in 2 main ways:

  • to group parameters in order to define priorities

  • to group together parameters in lists that must be passed together in a single field.

$”discount” * ($”cost” + $“VAT”)

sum(($”Monday_sales”, $”Tuesday_sales”, $”Wednesday_sales”))

,

The comma separates parameters in a list.

sum(($”Monday_sales”, $”Tuesday_sales”, $”Wednesday_sales”))

:

The colon indicates a range between columns. It must be used as part of a list, and consequently be delimited by brackets.

sum(($”Monday_sales” : $”Wednesday_sales”))

-

Minus operator.

$”Difference in cost" = $”Cost of oranges today"-$”Yesterday's cost"

+

Plus operator.

$”Transport Cost” = $”Petrol Cost” + $”Motorway Charges”

*

Product operator.

$“Total Sales of Item1” = $”Item1 Sold” * $”Item1 Cost”

^

Power operator

$”Area square room” = $”Length wall”^2

<

Less than angle bracket

$”SalesTrend” = ifelse($"Weekly Sales” < $"Last Week Weekly Sales”,"Decrease",Increase”)

>

Greater than angle bracket

$”SalesTrend”= ifelse($"Sales Difference"> 0,"Increase","Decrease")

!=

Does not equal, is different from.

$”Type of year” = ifelse($"DaysInYear" != 365,$”LeapYear”, $”Normal Year”)

\

Backslash is the escape character and it has 2 uses inside a string:

  • it can be used when you need to embed a string within a string - the backslash before the quotes allows you to do that.

  • it indicates special characters in strings

If we want to insert a real backslash in a string, itself must be escaped ( \\ )

$“Monthly \”deals”

“This string must be\non two lines” means start a new line

“I want to print backslash \\

/

Division operator

$”Transport Cost per Truck” = $”Transport Cost” / $”Number of Trucks”

==

Equals in comparisons.

The “=” symbol, which assigns a value, is inserted automatically between the left and right side of the formula by Rulex.

$”Item Cost” == 5

%

Modulo operator (it evaluates the rest in a division)

$”Money of Tip” = $”Total Payed” % $”Bill cost”

The following operators are still used in older versions of Rulex (Rulex 3.2) but have been replaced in Rulex 4

Legacy operator

Substituted with

Function & Examples

!

not

$”Type of year” = ifelse(!($"DaysInYear" == 365),$”LeapYear”, $”Normal Year”)

$”Type of year” = ifelse(not ($"DaysInYear" == 365),$”LeapYear”, $”Normal Year”)

&

and

$”IsMyCar” = $”NameOwner” == $”MyName” & $”SurnameOwner” == $”MySurname”

$”IsMyCar” = $”NameOwner” == $”MyName” and $”SurnameOwner” == $”MySurname”

|

or

$”IsBirthday” = $”Today” == $”BirthdayDate” | $”YesterdayAge” != $”TodayAge”

$”IsBirthday” = $”Today” == $”BirthdayDate” or $”YesterdayAge” != $”TodayAge”

The following operators are expressed as words:

Operator Word

Function

Examples

is

Equals to.

This operator is different from the “==” symbol because it returns a binary True or False value in any case. This is particularly important when dealing with the None value.

  • 5 is None, produces the result False

  • None is None, produces the result True

Whereas:

  • 5 == None, produces the result None

  • None == None, produces the result None

not is

Does not equal, is different from.

This operator is different from the “!=” symbol because it returns a binary True or False value in any case. This is particularly important when dealing with the None value.

  • 5 not is None, produces the result True

  • None not is None, produces the result True

Whereas:

  • 5 != None, produces the result None

  • None != None, produces the result None

in

This operator returns a binary value. It returns True for any element of the first column which is contained in the second column.

$”MyFavouriteColor” in $”HerFavouriteColor” will return True for all the entries in $”MyFavouriteColor” attribute which are inserted also in $”HerFavouriteColor” attribute and False for the other ones.

  • Strings can contain any characters, but must always enclosed with the symbol “. For example, “sales”.

  • Variable names can contain letters (capital and small), numbers and underscore only. Process variables must be introduced by @.