← rank operator page · aggregate/rank/partition_order/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

rank in calc, partitioned by Id_1 and Id_2 and ordered by Me_1, with a tie.

Manual:

Rank, Example 1, output verbatim: "If some Data Points are in the same order according to the specified orderClause, the same order number (rank) is assigned and a gap appears in the sequence of the assigned ranks".

Expected:

in XX, 3, 4, 6 and 7 rank 1 to 4; in YY, the two 5s rank 1, then 9 ranks 3 and 10 ranks 4.

script.vtl ⇩

DS_r := DS_1 [ calc Me_2 := rank ( over ( partition by Id_1 , Id_2 order by Me_1 ) ) ];

input/DS_1.csv ⇩

Id_1Id_2Id_3Me_1Me_2
AXX200031
AXX200149
AXX200275
AXX200368
AYY200093
AYY200154
AYY2002102
AYY200357

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_3", "type": "Time_Period", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3Me_1Me_2
AXX200031
AXX200142
AXX200274
AXX200363
AYY200093
AYY200151
AYY2002104
AYY200351

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "Id_3", "type": "Time_Period", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"},
        {"name": "Me_2", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}