Skip to main content

PQL46 (PQL Function Library - CPM 4.6)

AVG

Applies to: CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4 CELONIS 4.5 CELONIS 4.6

Description

This aggregate function calculates the average of a set of values.

AVG calculates the average of an or FLOAT column. The data type of the result is always a FLOAT (Since: CELONIS 4.5).

Syntax
AVG ( table.column )
NULL handling

NULL values are ignored, meaning that they do not influence the result. If all values of a group are NULL, the result for this group is also NULL.

Tips

If the size of the source column greatly exceeds the number of aggregated groups, the average for each group will be executed in parallel. Therefore, to achieve a good performance, multiple CPU cores and balanced aggregation (as described) are preferable (Since:  CELONIS 4.3).

Examples

[1] Calculating the average of four small integers.

Query

Column1

AVG ( "Table1"."Column" )

Input

Output

Table1

Column : INT

-1

1

3

7

Result

Column1 : FLOAT

2.5

[2] Calculating the average of values grouped by country.

Query

Column1

"Table1"."Country"

Column2

AVG ( "Table1"."Values" )

Input

Output

Table1

Country : STRING

Values : INT

'DE'

10

'US'

2

'FR'

10

'DE'

3

'US'

40

'DE'

5

'US'

3

Result

Column1 : STRING

Column2 : FLOAT

'DE'

6.0

'FR'

10.0

'US'

15.0

[3] Calculating the average of values mixed with nulls, grouped by country.

Query

Column1

"Table1"."Country"

Column2

AVG ( "Table1"."Values" )

Input

Output

Table1

Country : STRING

Values : INT

'FR'

10

'FR'

null

'DE'

Country : STRING

Result

Column1 : STRING

Column2 : FLOAT

'DE

null

'FR'

10.0

See also: