A function is an expression that returns a value. There are buttons for all the Arezzo functions in the Expression Builder.
See an alphabetic list of all functions and operators...
Arezzo functions can divided into the following categories:
Expression |
Description |
isknown(DataName) |
Condition is true if a value exists for the data name. For example: isknown(reg_date) or isknown(Screening:cover:DOB) |
It is advisable to use isknown with the logical operator not to avoid unexpected results concerning unknown data.
For example, the condition 'not q1 = 8' evaluates to true if q1 has a value that is not 8, but it also evaluates to true when q1 does not have a value as a result of not having been filled in.
If you use isknown as well as not you could create the condition 'isknown(q1) and not q1 = 8'
This evaluates to false when q1 has not been filled in, avoiding confusion.
Note that the condition 'isknown(q1) and not q1 = 8' is equivalent to 'q1 <> 8'
This is because <> is treated as a single operator, whereas "not q1 = 8" the "not" is applied after the "=" has been evaluated.
You cannot use isknown in a validation to check the currently entered value (by using 'isknown(me:value)'), because validations are only run after a value has been entered. Validations are not run on blank questions, so there is no way to validate an empty value.
Expression |
Description |
if(Condition,Expression1,Expression2) |
Evaluates to Expression1 if Condition is true, or Expression2 if Condition is false, e.g. if(age<18,'child','adult') |
case((Cond1,Expr1),(Cond2,Expr2),...) |
Conditional evaluation equivalent to nested 'if' expressions - evaluates to Expr1 if Cond1 is true, Expr2 if Cond2 is true, and so on, e.g. case((viral_load<500,'low'),(viral_load>10000,'high'),(viral_load between (500,10000),'intermediate')) |
case((Cond1,Expr1),...,(else,ExprN)) |
Similar to 'case' above - evaluates to expression1 if condition1 is true, and so on, but includes an extra expressionN to be returned if none of the conditions are true, e.g. case((viral_load<500,'low'),(viral_load>10000,'high'),(viral_load between (500,10000),'intermediate'),(else,'unknown')) |
If you do not use "else" in a "case" expression, and none of the conditions match, the expression will fail to evaluate. And if that "case" expression is part of a larger expression, this could cause a failure to evaluate the whole expression. Adding "else" ensures that something is always returned. See example
These functions can only be used with text expressions.
Expression |
Description |
substring( Text, StartPos, NChars ) |
Returns NChars characters from the given Text string starting at position StartPos. The first character is at position 1. For example substring( SubjName, 1, 3 ) returns the first 3 characters of the value of SubjName. If StartPos is negative, the position is counted from the end of the string. For example substring( SubjName, -1, 1 ) returns the last character of the value of SubjName. |
len( Text ) |
Returns the length of the given text string, i.e. the number of characters in the string. |
Also see comparison operator like.
These functions can only be used with numeric expressions. Arezzo also includes the normal arithmetic operators.
Expression |
Description |
abs( Expr ) |
The absolute value of Expr. This is its positive numeric value, ignoring any minus sign. |
neg( Expr ) |
The negative value of Expr. This is its negative numeric value, ignoring any plus sign. |
sqrt( Expr ) |
The square root of Expr. |
log( Expr ) |
The base 10 logarithm of Expr. |
round( Expr, Places ) |
This rounds Expr to the specified number of decimal places. This is useful when displaying the results of calculations within text messages, for example 'The value ' & round( sqrt(Q1), 2 ) & ' is too high'
You can use the round function to get the integer part of a real number by rounding to 0 decimal places.
Please note that the round function uses Banker's Rounding in which numbers of the form x.5 are rounded to the nearest even integer. This method avoids a bias towards consistently rounding up or down. For example, the following expressions give the following results:
round( 0.5, 0 ) = 0 round( 1.5, 0 ) = 2 round( 2.5, 0 ) = 2 round( 3.5, 0 ) = 4 round( 4.5, 0 ) = 4
To always round a value up, add 0.5 before rounding e.g. round( Q1 + 0.5, 0 )
To always round a value down, subtract 0.5 before rounding e.g. round( Q1 - 0.5, 0 )
|
Also see comparison operator between.
When creating any Arezzo conditions that check decimal numbers, the arithmetic rounding process within the base operating system can occasionally cause incorrect results. We recommend not using the '=' operator in a comparison with a calculated value without specifying the number of decimal places to compare, as any minor rounding variation may cause this to unexpectedly return false.
For example, to get the decimal part of a current value, it is necessary to subtract the integer part, obtained by rounding to 0 decimal places. Subtracting 0.5 ensures that the integer value will always be rounded down. The Arezzo expression for this is:
me:value – round( me:value – 0.5, 0 )
However, there may be very small arithmetic accuracy issues in the computer's base operating system, so that the following condition (to check whether the decimal part of a number is 0.7 or greater) will evaluate incorrectly for some values:
me:value – round( me:value – 0.5, 0 ) >= 0.7
To avoid these false results, it is necessary to specify that the comparison should be evaluated to an accuracy of 1 decimal place, i.e.
round( me:value – round( me:value – 0.5, 0 ), 1 ) >= 0.7
In general, when comparing real numbers for equality, it is advised to use the round function to specify an exact number of decimal places for each side of the comparison.
There are several functions in Arezzo that let you compare and manipulate date/time questions. Go to help for date/time functions...