Basic Concepts
Arithmetic Functions
You can perform simple arithmetic, such as addition, subtraction, multiplication and division:
Use of Brackets
You can use brackets to specify the order in which different operations are performed:
Brackets can be nested to any depth:
Positive and Negative Numbers
Numbers can positive or negative:
Decimals
You can use whole numbers or decimals:
Rounding
The following rounding functions are provided for convenience:
Round to nearest whole number
Round to fixed decimal places
Round down to whole number
Round up to whole number
Whitespace
Whitespace is ignored (Except in strings, see below):
Referencing Existing Field Values
Existing fields can be referenced using square brackets:
Literal Strings
String values can be specified using double quotes and they can be joined using an ampersand:
Whitespace contained in a string is an exception to the rule that whitespace is ignored:
The following characters are all supported:
Lower Case: a - z
Upper Case: A - Z
Digits: 0 - 9
Spaces:
Other Printable Characters: \!#$%&'()*+,-./:;<=>?@[ ]^_`{|}~
Note: Double quotes inside literal strings are not currently supported, but they can be contained in a field value and should act as expected in that case.
String Padding
You can pad a string with leading or trailing characters. This is often used for padding numbers with leading zeroes, but you can pad any string with any characters. The syntax is:
- LPAD(string, length, padding)
- RPAD(string, length, padding)
Examples:
LPAD("Z", 5, "A") => "AAAAZ"
LPAD("YZ", 5, "A") => "AAAYZ"
LPAD("XYZ", 5, "A") => "AAXYZ"
RPAD("A", 5, "Z") => "AZZZZ"
RPAD("AB", 5, "Z") => "ABZZZ"
RPAD("ABC", 5, "Z") => "ABCZZ"
Practical Example: