Here, the report expression engine operators and functions are described.
Notes
Incorrect
dataset_field_val(1, Cust_Name)
Correct
dataset_field_val(1, 'Cust_Name')
Explanation: In this example, a database field name is a parameter of String (Text) type, so it should be enclosed in single quotes.
Incorrect
Book title: dataset_field_val(1, 'TITLE')
Correct
'Book title: ' + dataset_field_val(1, 'TITLE')
Book title: <<<dataset_field_val(1, 'TITLE')>>>
Explanation: To produce one value, the number of operands in a String (Text) expression must be equal to the number of operators plus one. In other words, there should be an operator between each two operands in a valid String expression.
Another solution is to separate dynamic parts of the expression. In reports context, dynamic parts begin with three opening triangle brackets (<<<) and end with three closing triangle brackets (>>>).
Operators
Arithmetic Operators
Work with numbers and return numbers (except + operator, which can be used for string concatenation).
| + | Addition of numbers. Can be also used for concatenating string operands (as an alternative for concat function). |
| - | Substraction of numbers |
| * | Multiplication of numbers |
| / | Division of numbers |
| ^ | Raises left operand to power, specified by the right operand (as an alternative for power function) |
| div | Integer division. It is division in which the fractional part (remainder) is discarded. |
| mod | Remainder of integers. It divides two numbers and returns only the remainder. |
Logical Operators
Work with boolean constants or expressions of any kind, which return a boolean value, and return boolean True or False.
| not | Logical NOT. Returns False if its single operand can be converted to True; otherwise, returns True. |
| and | Logical AND. Returns True if both operands are True; otherwise, returns False. |
| or | Logical OR. Returns True if either operand is True; if both are False, returns False. |
| xor | Exclusive OR. Returns True if one operand is True and the other is False; otherwise, returns False. |
| = | Equality |
| <> | Inequality |
| > | Greater than |
| >= | Greater than or equal |
| < | Less than |
| <= | Less than or equal |
Functions
Use functions to calculate values. Each function returns one value. Function parameters can be constants or expressions (including recursive function calls), unless otherwise noted below.
Database Related Functions
General
dataset_row_number( StepNo Integer, GroupLevel Integer ): Integerdataset_group_number( StepNo Integer, GroupLevel Integer ): Integerdataset_field_val( StepNo Integer, FieldName String | FieldIndex Integer ): <FieldType>dataset_field_hex_val( StepNo Integer, FieldName String | FieldIndex Integer ): Stringdataset_field_is_null( StepNo Integer, FieldName String | FieldIndex Integer ): Booleandataset_nvl( StepNo Integer, FieldName String | FieldIndex Integer, SubstVal <FieldType> ): <FieldType>dataset_field_exists( StepNo Integer, FieldName String ): Booleandataset_param_val( StepNo Integer, ParamName String ): <ParamType>query_res( StepNo Integer, SqlText String ): <FieldType>Statistical (Aggregate)
These functions perform calculation on current dataset data. Unlike other functions, statistical functions accumulate data of each record of dataset field, therefore they need more resources and their using (especially for conditional functions) may slow down processing for large datasets.
It is strongly recommended to use these functions only inside or after loop(s) through dataset rows, otherwise they will return inadequate values.Standard (similar to aggregate functions in SQL)
dataset_row_count( StepNo Integer, GroupLevel Integer ): Integerdataset_min( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_max( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_sum( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_avg( StepNo Integer, GroupLevel Integer, FieldName String ): Numericdataset_count( StepNo Integer, GroupLevel Integer, FieldName String ): IntegerConditional
These functions work like standard statistical functions, but with one important difference: they check Condition for each row, and calculate only if it evaluates to True. It is important to write the Condition parameter in these functions as String constant (i.e. enclosed in single quotes) or a string deterministic expression (see below).
The parameters of these functions must be constants or deterministic expressions (i.e. return the same result any time they are called with a specific set of input values). The Condition parameter can use also nondeterministic expressions, but, as noted above, it should be written as string literal or string deterministic expression.
dataset_row_count_ex( StepNo Integer, GroupLevel Integer, Condition String ): Integerdataset_min_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_max_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_sum_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_avg_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): Numericdataset_count_ex( StepNo Integer, GroupLevel Integer, FieldName String, Condition String ): IntegerIt is not recommended to use nested calls of statistical functions (i.e. when Condition contains statistical functions calls), because the application cannot guarantee the correct result of such calls.
But if you do this, try to avoid cyclic field references in these functions because this may cause unexpected results of expressions. For example, using FieldName inside Condition is a cyclic reference and should be avoided.Examples of correct using of conditional statistical functions:
dataset_sum_ex(1, 0, 'PaymentSum', 'dataset_field_val(1, ''CustNo'') > 1000')
(this expression will sum data from PaymentSum field, when value of numeric field CustNo is larger then 1000)
dataset_count_ex(1, 0, 'CustNo', 'dataset_field_val(1, ''Paid'')')
(this expression will return count of values from field CustNo, when value of boolean field Paid is True)
dataset_sum_ex(1, 0, 'BillSum', 'dataset_sum_ex(1, 0, ''OldBillSum'', ''dataset_field_val(1, ''''CustNo'''') > 0'') > 0')
(this function will return sum of values from field BillSum, when conditional sum of field OldBillSum is larger than 0)
Examples of incorrect using of conditional statistical functions:
dataset_count_ex(1, 0, 'CustNo', 'yes')
(error: not boolean constant cannot be used as condition)
dataset_sum_ex(1, 0, 'BillSum', 'dataset_sum_ex(1, 0, ''OldBillSum'', ''dataset_sum_ex(1, 0, ''''BillSum'''', True) > 0'') > 0')
(error: cyclic reference for field BillSum)
Mathematical Functions
abs( x Numeric ): Numericceil( x Numeric ): Numericfrac( x Numeric ): Numericint( x Numeric ): Numericmax( x Numeric, y Numeric ): Numericmin( x Numeric, y Numeric ): Numericround( x Numeric ): Integersqrt( x Numeric ): Numericpower( x Numeric, y Numeric ): Numericexp( x Numeric ): Numericln( x Numeric ): Numericcos( x Numeric ): Numericsin( x Numeric ): Numerictan( x Numeric ): Numericatan( x Numeric ): NumericDate and Time Functions
date: DateTimetime: DateTimeadd_date_time( x DateTime, y Numeric ): DateTimecompare_date_time( Date1 DateTime, Date2 DateTime ): Integerdate_time_diff( Date1 DateTime, Date2 DateTime ): Numericformat_date_time( x DateTime, Mask String ): StringFile Related Functions
file_created( FileName String ): DateTimefile_last_modified( FileName String ): DateTimefile_last_accessed( FileName String ): DateTimefile_size( FileName String ): Numericfile_version( FileName String ): Stringextract_file_ext( FileName String ): Stringextract_file_name( FileName String ): Stringextract_file_dir( FileName String ): Stringextract_file_path( FileName String ): Stringextract_file_text( FileName String ): Stringfile_exists( FileName String ): Booleandir_exists( DirectoryName String ): BooleanMiscellaneous Functions
capitalize( Str String, ): Stringchar( x Integer ): Stringconcat( Str1 String, Str2 String ): Stringformat_float( x Numeric, Mask String ): Stringiif( Condition Boolean, x <AnyType>, y <AnyType> ): <AnyType>length( Str String, ): Integerlower( Str String, ): Stringlpad( Str String, Count Numeric, Char String ): Stringnumber_to_words( x Numeric, Language String, Options String ): Stringordinal_number( x Integer, Language String, Case String, Gender String ): Stringparse( x <AnyType> ): <AnyType>pos( SubStr String, Str String ): Integerpretty( Str String, ): Stringquantitative_numeral( x Integer, Language String, Case String, Gender String ): Stringrgb( Red Integer, Green Integer, Blue Integer ): Stringrpad( Str String, Count Numeric, Char String ): Stringstring_replace( Str String, SubStr String, NewSubStr String ): Stringsubstr( Str String, Index Integer, Count Integer ): Stringsubstr_count( Str String, SubStr String ): Integerto_number( <AnyType> String ): Numericto_string( <AnyType> String ): Stringtrim( Str String, ): Stringtrim_left( Str String, ): Stringtrim_right( Str String, ): Stringupper( Str String, ): StringReport Specific Functions
report_author: Stringreport_changed_by: Stringreport_database_name: Stringreport_dataset_name: Stringreport_description: Stringreport_file_name: Stringpage_left_margin: Integerpage_right_margin: Integerpage_top_margin: Integerpage_bottom_margin: Integerpage_number: Integerpage_count: Integerpage_height: Integerpage_width: Integerinternal_property( PropertyName String ): StringObsolete Report Functions
GROUPRECORDNUMBER This function is no longer supported. Use dataset_row_number instead NUMTOWORDS This function is no longer supported. Use number_to_words instead DATASETNAME Use report_dataset_name instead DATABASENAME Use report_database_name instead FILENAME Use report_file_name instead PAGEHEIGHT Use page_height instead PAGEWIDTH Use page_width instead LEFTMARGIN Use page_left_margin instead RIGHTMARGIN Use page_right_margin instead TOPMARGIN Use page_top_margin instead BOTTOMMARGIN Use page_bottom_margin instead PAGENUMBER Use page_number instead RECORDNUMBER Use dataset_row_number instead PAGERECORDNUMBER Use dataset_row_number instead GROUP1RECORDNUMBER Use dataset_row_number instead GROUP2RECORDNUMBER Use dataset_row_number instead GROUP3RECORDNUMBER Use dataset_row_number instead RECORDCOUNT Use record_count instead REPORTDESCRIPTION Use report_description instead REPORTAUTHOR Use report_author instead PAGECOUNT Use page_count instead MIN Use dataset_min instead MAX Use dataset_max instead SUM Use dataset_sum instead AVERAGE Use dataset_avg instead COUNT Use dataset_count instead MINEX Use dataset_min_ex instead MAXEX Use dataset_max_ex instead SUMEX Use dataset_sum_ex instead AVERAGEEX Use dataset_avg_ex instead COUNTEX Use dataset_count_ex instead FILESIZE Use file_size instead FIELDVAL Use dataset_field_val instead PARAMVAL Use dataset_param_val instead ISNULL Use dataset_is_null instead FIELDEXISTS Use dataset_field_exists instead NVL Use dataset_nvl instead QUERYRES Use query_res instead STR Use to_string instead TRIMLEFT Use trim_left instead TRIMRIGHT Use trim_right instead ORDINALNUMBER Use ordinal_number instead QUANTITATIVENUMERAL Use quantitative_numeral instead FILECREATED Use file_created instead FILELASTMODIFIED Use file_last_modified instead FILELASTACCESSED Use file_last_accessed instead EXTRACTFILENAME Use extract_file_name instead EXTRACTFILEEXT Use extract_file_ext instead EXTRACTFILEDIR Use extract_file_dir instead EXTRACTFILEPATH Use extract_file_path instead REPLACE Use string_replace instead ADDDATETIME Use add_date_time instead COMPAREDATETIME Use compare_date_time instead DATETIMEDIFF Use date_time_diff instead FORMATDATETIME Use format_date_time instead SUBSTRCOUNT Use substr_count instead