Functions

Top  Previous  Next

See the topic about fields in templates for a general description of the syntax.

See the topic about cross-tab reports.

This type of field allows inserting the result of an aggregate functions in cross-tab tables.

Functions are not available for non-cross-tab tables. If you want to add summary row(s) or column(s) for non-cross-tab tables, you can:

calculate them using SQL functions, if you use SQL data queries, or

use OnProcessRecord event to calculate the function in a variable.

Syntax

<function> ::= =<function name>(<param>)[ <field type>][ "<format>"]

<function name> ::= min | max | sum | average | count | var.p | var.s | stddev.p | stddev.s | <custom function name>

<param> ::= <field name>

<field type> – see "function results types" sections below.

<format> – see "format strings" sections below.

<custom function name> – see "additional functions" below.

About functions

This type of field allows inserting the result of an aggregate functions in cross-tab tables. It is not valid in all other places.

The argument of this function may be one of numeric value fields (see the topic about cross-tab reports).

In other words, <param> is a name of one of data fields in the result of application of one of Table.RowGenerationRules[].DataQuery, providing that it:

is not listed in Table.CrossTabulation.Levels[].FieldName

is not listed in Table.RowGenerationRules[].KeyFieldNames

have the type either rvrftInteger or rvrftFloat.

A set of values of this parameter (used to apply the function) depends on the place of insertion of this field code:

outside report tables, in a non-cross-tab report tables: not valid (no values)

in rows of a cross-tab header or above: not valid (no values)

in the cells located in the intersection of rows corresponding to RowGenerationRules[] and:

o... data columns of the cross-tab headers: not valid (no values)

o... summary columns of the cross-tab header: values corresponding to this summary columns and this row

o... all other columns: all values corresponding to this row

in the cells located in the intersection of all other rows and

o... data columns of the cross-tab headers: all values of this column

o... summary columns of the cross-tab header: all values corresponding to this summary columns and all rows

o... all other columns: all values

hmtoggle_arrow1Example

Functions list

<function name>

Meaning

Result type

Minimal necessary count of input values

min

returns the smallest value

type of the parameter

1

max

returns the largest value

1

sum

calculates the sum of values

0

count

returns the count of values

int

0

average

returns the average value (arithmetic mean)

average

float

1

var.p

calculates variance (based on the entire population)var_p

1

var.s

estimates variance based on a sample

var_s

2

stddev.p

calculates standard deviation (based on the entire population)

stddev_p

1

stddev.s

estimates standard deviation based on a sample

stddev_s

2

If function cannot be calculates (because it is inserted in a wrong context, or because of not enough input values), a report generator inserts Texts.InvalidFunctionResult in place of the function field.

Additional functions

In addition to the functions listed above, programmers can implement their own functions.

As an example, ReportWorkshop includes TRVReportMedianCalculator unit implementing median.

<custom function name>

Meaning

Result type

Minimal necessary count of input values

median

calculates the median

float

1

See also: extending Report Workshop

Functions results types

As you can see from the table above, a function may return either integer or floating point value.

You can override the result type by specifying <field type>, read the topic about specifying data field types.

Data field format strings

Read the topic about format strings.

Format string is not applied to Texts.InvalidFunctionResult.


Report Workshop © trichview.com