Description
INDEX_ORDER
returns a column with
integer indices, starting from 1
. The indices
indicate the order of the rows.
The INDEX_ORDER
function creates an INT index
column. The index column contains a unique integer value for
every row of a required reference input column.
INDEX_ORDER
can be applied to INT,
FLOAT,
DATE or STRING columns.
The result is a column of type INT.
Syntax
INDEX_ORDER returns integer indices based on the given sorting and partition. In this preferred syntax, ORDER BY and PARTITION BY can be used to define the sorting and partitioning that should be used (Since: CELONIS 4.7):
INDEX_ORDER ( column [, ORDER BY ( sort_column [sorting], ... )] [, PARTITION BY ( partition_column, ... )] )
- column: The source column on which the index column will be based.
- sort_column: Optional sorting column to specify an order.
- sorting: Each of these columns can have an optional tag specifying the ordering of the column. Default is ascending:
- ASC: Ascending order
- DESC: Descending order
- partition_column: Optional partition column to specify groups in which
INDEX_ORDER
should operate.
Ordering
One or more columns can be given to specify an ordering. This tells the INDEX_ORDER
function what the
preceding element actually is. Optionally every column can be tagged as ascending or descending. Equal input values
are always given distinct output indices. The indices for a given range of equal input values are incremented
starting from the topmost value of this range of the input column:
Partitioning
The partition columns specify groups. The INDEX_ORDER
function operates independently within every
group. This means when an ordering is given it is applied within every group.
Null handling
NULL values are ignored, meaning that the NULL value rows stay NULL in the result column and will not count as an index order value.
Deprecated Behavior
As an alternative to the recommended syntax, the INDEX_ORDER function can be called as follows: [ DEPRECATED SINCE 4.7 ].
INDEX_ORDER ( <column> [, <sorting> ] [, GROUP( <group_column>, ... ) ] )
- column: The source column on which the index column will be based.
- sorting: An optional sorting of the indices, which defaults to ascending.
- ASC: Ascending index order values.
- DESC: Descending index order values.
- grouping: Optional grouping columns. Independent index order ranges will be created for each group, all starting from 1.
Examples
Column1
INDEX_ORDER ( "Table1"."Date" )
Column1
"companyDetail"."country"
Column2
INDEX_ORDER ( "caseTable"."value" )
Column1
"companyDetail"."country"
Column2
INDEX_ORDER ( COUNT_TABLE ( "caseTable" ) )
Column1
INDEX_ORDER ( "Table1"."Date" , ORDER BY ( "Table1"."Date" ) )
Column1
"countryDetail"."country"
Column2
INDEX_ORDER ( "countryDetail"."value" , ORDER BY ( "countryDetail"."value" ) , PARTITION BY ( "countryDetail"."country" ) )
caseTable
countryDetail
Foreign Keys
countryDetail.value | caseTable.value |
Column1
"countryDetail"."country"
Column2
"countryDetail"."city"
Column3
INDEX_ORDER ( "countryDetail"."value" , ORDER BY ( "countryDetail"."value" ) , PARTITION BY ( "countryDetail"."country" , "countryDetail"."city" ) )
caseTable
countryDetail
Foreign Keys
countryDetail.value | caseTable.value |
Advanced Example: Case Coverage
The INDEX_ORDER
function allows to calculate KPIs, that require sorting. One example is calculating
how many cases are covered by the N most common
process variants:
Column1
"Cases"."CITY"
Column2
VARIANT ( "Activities"."ACTIVITY" )
Column3
COUNT ( "Cases"."CASE_ID" )
Activities
CASE_ID : INT | ACTIVITY : STRING | TIMESTAMP : DATE |
---|---|---|
1 | 'A' | Fri Feb 01 2019 00:00:00.000 |
1 | 'B' | Sat Feb 02 2019 00:00:00.000 |
1 | 'C' | Sun Feb 03 2019 00:00:00.000 |
2 | 'A' | Fri Mar 01 2019 00:00:00.000 |
2 | 'B' | Sat Mar 02 2019 00:00:00.000 |
2 | 'C' | Sun Mar 03 2019 00:00:00.000 |
3 | 'A' | Mon Apr 01 2019 00:00:00.000 |
3 | 'B' | Tue Apr 02 2019 00:00:00.000 |
3 | 'C' | Wed Apr 03 2019 00:00:00.000 |
4 | 'A' | Wed May 01 2019 00:00:00.000 |
4 | 'B' | Thu May 02 2019 00:00:00.000 |
4 | 'C' | Fri May 03 2019 00:00:00.000 |
5 | 'R' | Sat Jun 01 2019 00:00:00.000 |
5 | 'S' | Sun Jun 02 2019 00:00:00.000 |
5 | 'T' | Mon Jun 03 2019 00:00:00.000 |
6 | 'A' | Mon Jul 01 2019 00:00:00.000 |
6 | 'B' | Tue Jul 02 2019 00:00:00.000 |
6 | 'C' | Wed Jul 03 2019 00:00:00.000 |
7 | 'R' | Thu Aug 01 2019 00:00:00.000 |
7 | 'S' | Fri Aug 02 2019 00:00:00.000 |
7 | 'T' | Sat Aug 03 2019 00:00:00.000 |
8 | 'R' | Sun Sep 01 2019 00:00:00.000 |
8 | 'S' | Mon Sep 02 2019 00:00:00.000 |
8 | 'T' | Tue Sep 03 2019 00:00:00.000 |
9 | 'R' | Tue Oct 01 2019 00:00:00.000 |
9 | 'S' | Wed Oct 02 2019 00:00:00.000 |
9 | 'T' | Thu Oct 03 2019 00:00:00.000 |
10 | 'X' | Fri Nov 01 2019 00:00:00.000 |
10 | 'Y' | Sat Nov 02 2019 00:00:00.000 |
10 | 'Z' | Sun Nov 03 2019 00:00:00.000 |
Cases
Foreign Keys
Cases.CASE_ID | Activities.CASE_ID |
- a count of how often a variant occurs per city.
- an index order, which gives an index sorted by how often the different variants occur, per city.
Column1
"Cases"."CITY"
Column2
VARIANT ( "Activities"."ACTIVITY" )
Column3
COUNT ( "Cases"."CASE_ID" )
Column4
INDEX_ORDER ( PU_COUNT ( DOMAIN_TABLE ( VARIANT ( "Activities"."ACTIVITY" ) , "Cases"."CITY" ) , "Cases"."CASE_ID" ) , ORDER BY ( PU_COUNT ( DOMAIN_TABLE ( VARIANT ( "Activities"."ACTIVITY" ) , "Cases"."CITY" ) , "Cases"."CASE_ID" ) DESC ) , PARTITION BY ( PU_FIRST ( DOMAIN_TABLE ( VARIANT ( "Activities"."ACTIVITY" ) , "Cases"."CITY" ) , "Cases"."CITY" ) ) )
Activities
CASE_ID : INT | ACTIVITY : STRING | TIMESTAMP : DATE |
---|---|---|
1 | 'A' | Fri Feb 01 2019 00:00:00.000 |
1 | 'B' | Sat Feb 02 2019 00:00:00.000 |
1 | 'C' | Sun Feb 03 2019 00:00:00.000 |
2 | 'A' | Fri Mar 01 2019 00:00:00.000 |
2 | 'B' | Sat Mar 02 2019 00:00:00.000 |
2 | 'C' | Sun Mar 03 2019 00:00:00.000 |
3 | 'A' | Mon Apr 01 2019 00:00:00.000 |
3 | 'B' | Tue Apr 02 2019 00:00:00.000 |
3 | 'C' | Wed Apr 03 2019 00:00:00.000 |
4 | 'A' | Wed May 01 2019 00:00:00.000 |
4 | 'B' | Thu May 02 2019 00:00:00.000 |
4 | 'C' | Fri May 03 2019 00:00:00.000 |
5 | 'R' | Sat Jun 01 2019 00:00:00.000 |
5 | 'S' | Sun Jun 02 2019 00:00:00.000 |
5 | 'T' | Mon Jun 03 2019 00:00:00.000 |
6 | 'A' | Mon Jul 01 2019 00:00:00.000 |
6 | 'B' | Tue Jul 02 2019 00:00:00.000 |
6 | 'C' | Wed Jul 03 2019 00:00:00.000 |
7 | 'R' | Thu Aug 01 2019 00:00:00.000 |
7 | 'S' | Fri Aug 02 2019 00:00:00.000 |
7 | 'T' | Sat Aug 03 2019 00:00:00.000 |
8 | 'R' | Sun Sep 01 2019 00:00:00.000 |
8 | 'S' | Mon Sep 02 2019 00:00:00.000 |
8 | 'T' | Tue Sep 03 2019 00:00:00.000 |
9 | 'R' | Tue Oct 01 2019 00:00:00.000 |
9 | 'S' | Wed Oct 02 2019 00:00:00.000 |
9 | 'T' | Thu Oct 03 2019 00:00:00.000 |
10 | 'X' | Fri Nov 01 2019 00:00:00.000 |
10 | 'Y' | Sat Nov 02 2019 00:00:00.000 |
10 | 'Z' | Sun Nov 03 2019 00:00:00.000 |
Cases
Foreign Keys
Cases.CASE_ID | Activities.CASE_ID |
- Numerator: Inside the PU_COUNT function we only select the variants that are among the two most common (
< 3
) for that city. - Denominator: We apply the PU_COUNT function on all variants.
Column1
"Cases"."CITY"
Column2
COUNT ( "Cases"."CASE_ID" )
Column3
PU_COUNT ( DOMAIN_TABLE ( "Cases"."CITY" ) , "Cases"."CASE_ID" , INDEX_ORDER ( PU_COUNT ( DOMAIN_TABLE ( VARIANT ( "Activities"."ACTIVITY" ) , "Cases"."CITY" ) , "Cases"."CASE_ID" ) , ORDER BY ( PU_COUNT ( DOMAIN_TABLE ( VARIANT ( "Activities"."ACTIVITY" ) , "Cases"."CITY" ) , "Cases"."CASE_ID" ) DESC ) , PARTITION BY ( PU_FIRST ( DOMAIN_TABLE ( VARIANT ( "Activities"."ACTIVITY" ) , "Cases"."CITY" ) , "Cases"."CITY" ) ) ) < 3 ) / PU_COUNT ( DOMAIN_TABLE ( "Cases"."CITY" ) , "Cases"."CASE_ID" )
Activities
CASE_ID : INT | ACTIVITY : STRING | TIMESTAMP : DATE |
---|---|---|
1 | 'A' | Fri Feb 01 2019 00:00:00.000 |
1 | 'B' | Sat Feb 02 2019 00:00:00.000 |
1 | 'C' | Sun Feb 03 2019 00:00:00.000 |
2 | 'A' | Fri Mar 01 2019 00:00:00.000 |
2 | 'B' | Sat Mar 02 2019 00:00:00.000 |
2 | 'C' | Sun Mar 03 2019 00:00:00.000 |
3 | 'A' | Mon Apr 01 2019 00:00:00.000 |
3 | 'B' | Tue Apr 02 2019 00:00:00.000 |
3 | 'C' | Wed Apr 03 2019 00:00:00.000 |
4 | 'A' | Wed May 01 2019 00:00:00.000 |
4 | 'B' | Thu May 02 2019 00:00:00.000 |
4 | 'C' | Fri May 03 2019 00:00:00.000 |
5 | 'R' | Sat Jun 01 2019 00:00:00.000 |
5 | 'S' | Sun Jun 02 2019 00:00:00.000 |
5 | 'T' | Mon Jun 03 2019 00:00:00.000 |
6 | 'A' | Mon Jul 01 2019 00:00:00.000 |
6 | 'B' | Tue Jul 02 2019 00:00:00.000 |
6 | 'C' | Wed Jul 03 2019 00:00:00.000 |
7 | 'R' | Thu Aug 01 2019 00:00:00.000 |
7 | 'S' | Fri Aug 02 2019 00:00:00.000 |
7 | 'T' | Sat Aug 03 2019 00:00:00.000 |
8 | 'R' | Sun Sep 01 2019 00:00:00.000 |
8 | 'S' | Mon Sep 02 2019 00:00:00.000 |
8 | 'T' | Tue Sep 03 2019 00:00:00.000 |
9 | 'R' | Tue Oct 01 2019 00:00:00.000 |
9 | 'S' | Wed Oct 02 2019 00:00:00.000 |
9 | 'T' | Thu Oct 03 2019 00:00:00.000 |
10 | 'X' | Fri Nov 01 2019 00:00:00.000 |
10 | 'Y' | Sat Nov 02 2019 00:00:00.000 |
10 | 'Z' | Sun Nov 03 2019 00:00:00.000 |
Cases
Foreign Keys
Cases.CASE_ID | Activities.CASE_ID |