Skip to main content

Celonis Product Documentation

PU_MODE
Description

Calculates the mode of the specified source column for each element in the given target table. For multi-modal input, where there are several result candidates, the element with the smallest value is chosen. For elements of type STRING, the smallest value is determined by its lexicographical order.

Syntax
 PU_MODE ( target_table, source_table.column [, filter_expression] )
  • target_table: The table to which the aggregation result should be pulled. This can be:

  • source_table.column: The column which should be aggregated for every row of the target_table.

  • filter_expression (optional): An optional filter expression to specify which values of the source_table.column should be taken into account for the aggregation.

NULL handling

If no value in the source table column exists for the element in the target table (either because all values of the source table are filtered out, or because no corresponding value exists in the first place), NULL will be returned. NULL values in the source table column are treated as if the row does not exist.

Examples

[1]

Calculate the mode of the case table values for each company code:

Query

Column1

         "caseTable"."companyCode"
        

Column2

         PU_MODE ( "companyDetail" , "caseTable"."value" )
        

Input

Output

caseTable

caseId : string

companyCode : string

value : int

'1'

'001'

200

'2'

'001'

200

'3'

'001'

100

'4'

'002'

200

'5'

'002'

150

'6'

'002'

150

'7'

'003'

150

'8'

'003'

500

'9'

'003'

500

'10'

'003'

200

companyDetail

companyCode : string

country : string

'001'

'DE'

'002'

'DE'

'003'

'DE'

Foreign Keys

caseTable.companyCode

companyDetail.companyCode

Result

Column1 : string

Column2 : int

'001'

200

'001'

200

'001'

200

'002'

150

'002'

150

'002'

150

'003'

500

'003'

500

'003'

500

'003'

500

[2]

Calculate the mode of the case table values for each company code:

Query

Column1

         "caseTable"."companyCode"
        

Column2

         PU_MODE ( "companyDetail" , "caseTable"."value" )
        

Input

Output

caseTable

caseId : string

companyCode : string

value : int

'1'

'001'

100

'2'

'001'

200

'3'

'001'

300

'4'

'002'

400

'5'

'002'

500

'6'

'002'

600

'7'

'003'

700

'8'

'003'

800

'9'

'003'

900

'10'

'003'

1000

companyDetail

companyCode : string

country : string

'001'

'DE'

'002'

'DE'

'003'

'US'

Foreign Keys

caseTable.companyCode

companyDetail.companyCode

Result

Column1 : string

Column2 : int

'001'

100

'001'

100

'001'

100

'002'

400

'002'

400

'002'

400

'003'

700

'003'

700

'003'

700

'003'

700

[3]

PU-functions can be used inside another aggregation function. In this example, the maximum value of all mode case table values for each company code is calculated:

Query

Column1

         MAX ( PU_MODE ( "companyDetail" , "caseTable"."value" ) )
        

Input

Output

caseTable

caseId : int

companyCode : string

value : int

1

'001'

600

2

'001'

400

3

'001'

200

4

'002'

300

5

'002'

300

6

'003'

200

companyDetail

companyCode : string

country : string

'001'

'DE'

'002'

'DE'

'003'

'US'

Foreign Keys

caseTable.companyCode

companyDetail.companyCode

Result

Column1 : int

300

[4]

Calculate the mode of the case table values for each company code. Only consider cases with an ID larger than 2:

Query

Column1

         "companyDetail"."companyCode"
        

Column2

         PU_MODE ( "companyDetail" , "caseTable"."value" , "caseTable"."caseID" > 2 )
        

Input

Output

caseTable

caseId : int

companyCode : string

value : int

1

'001'

600

2

'001'

400

3

'001'

200

4

'002'

300

5

'002'

300

6

'003'

200

companyDetail

companyCode : string

country : string

'001'

'DE'

'002'

'DE'

'003'

'US'

Foreign Keys

caseTable.companyCode

companyDetail.companyCode

Result

Column1 : string

Column2 : int

'001'

200

'002'

300

'003'

200

[5]

Calculate the sum of the case table values for each company code. Only consider cases with an ID larger than 3. All case table values for companyCode '001' are filtered out, which means that in this case, NULL is returned.

Query

Column1

         "companyDetail"."companyCode"
        

Column2

         PU_MODE ( "companyDetail" , "caseTable"."value" , "caseTable"."caseID" > 3 )
        

Input

Output

caseTable

caseId : int

companyCode : string

value : int

1

'001'

600

2

'001'

400

3

'001'

200

4

'002'

300

5

'002'

300

6

'003'

200

companyDetail

companyCode : string

country : string

'001'

'DE'

'002'

'DE'

'003'

'US'

Foreign Keys

caseTable.companyCode

companyDetail.companyCode

Result

Column1 : string

Column2 : int

'001'

null

'002'

300

'003'

200

See also: