← analytic_invocation operator page · aggregate/analytic_invocation/partition_by/sum_per_quarter

Sum per quarter 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

partition by Id_2: the sum of Me_1 in calc over the data points of the same quarter.

Manual:

Analytic invocation: "The input Data Set is partitioned according to the values of one or more Identifier Components"; with no window clause, the window is the whole partition.

Expected:

Me_3 = 3 + 4 = 7 for 2020Q1, 1 + 8 = 9 for 2020Q2, 5 for 2021Q1 and 1 for 2021Q2.

script.vtl ⇩

DS_r := DS_1 [ calc Me_3 := sum ( Me_1 over ( partition by Id_2 ) ) ];

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
A2020Q131.500000
A2020Q213.500000
A2021Q152.500000
A2021Q210.500000
B2020Q146.500000
B2020Q284.500000

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2Me_3
A2020Q131.5000007
A2020Q213.5000009
A2021Q152.5000005
A2021Q210.5000001
B2020Q146.5000007
B2020Q284.5000009

expected/DS_r.json ⇩

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