The values in the calculation fields are calculated from the expressions specified by you.
The following types of expressions are supported:
- Mathematical - Expression involving numbers.
- String - String can also be added together, compared, etc...
- Boolean - Expression that evaluate to true (1.0) and false (0.0).
Numeric and string types can not be mixed in a left / right operand pair. Use
|
Variables
|
Variables are values of other fields in the same record.
Variable must be enclosed by a pound sign and open brace #{ and a closed brace }.
i.e. expression = "#{field_name1} + #{field_name2}"
String values/variables must be enclosed by Quote characters:
Example: 'Result: ' + '#{string_field1}' + '#{string_field2}'
|
Operators
|
The following operators are supported:
- ( open parentheses
- ) closed parentheses
- + addition (for numbers and strings)
- - subtraction
- * multiplication
- / division
- % modulus
- == equal (for numbers and strings)
- != not equal (for numbers and strings)
- < less than (for numbers and strings)
- <= less than or equal (for numbers and strings)
- > greater than (for numbers and strings)
- >= greater than or equal (for numbers and strings)
- && boolean and
- || boolean or
- ! boolean not
|
Result type
|
For each calculation, there must be a correct result type set:
- "Real result" and "Integer result" are used for expressions with numerical result.
- "Date/Time result" is used to represent the result in form of date and time. The calculation result is interpreted as the number of seconds that has passed since January 1, 1970 (UNIX time).
- "Date result" is the same as the previous type, but displays only the date.
- "String result" is used for expressions that contain string manipulations or functions that return a string.
|
Examples
|
Example 1:
Entries contain fields: Price, Count
We add a calculating field "Sum" by using the following expression:
#{Price}*#{Count}
Example 2:
Entries contain fields: Count, Total
We add a calculating field "Percentage" by using the following expression:
(#{Count } / #{ Total }) * 100
Example 3:
Entries contain fields: StartDateTime, EndDateTime
We add a calculating field "Duration" by using the following expression (result is number seconds):
#{EndDateTime} - #{StartDateTime}
Example 4:
Entries contain fields: StartDate, EndDate
We add a calculating field "Days" by using the following expression:
datediff(#{EndDate} , #{StartDate})
Example 5:
Entries contain fields: Time
We add a calculating field "Days left" by using the following expression:
if( #{Time} > now() , rint((#{Time} - now())/(60*60*24)) , 'in the past')
|
Notes
|
Variable names can not break any of the following rules:
- can not start with a number
- can not contain an operator (see the above list of operators)
- can not contain a quote character - single or double
- can not contain a brace character - open or closed
- can not contain one of the following special characters: #, ~ , ^ !
Notes on expression parsing:
- Spaces are ignored when parsing expressions.
- The expression is evaluated as one or more subexpressions.
Subexpressions within open parentheses and closed parentheses are evaluated
before other parts of the expression.
- Subexpressions at the same level are evaluated from left to right.
- Operators with with the same precedence are evaluated from left to right.
|