← max operator page · aggregate/max/ds_group_all/quarters_to_years

Quarters to years 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

max with the deprecated group all time_agg ( "A" ), which turns each quarter of Id_2 into its year, written 2020 or 2021.

Manual:

Aggregate invocation: "group all: converts the values of an Identifier Component using conversionExpr and keeps all the resulting Identifiers"; Time aggregation: "On time_period type, the operator maps the input value into the comprising larger time period specified by the periodIndTo parameter".

Expected:

Id_1, the year and the two measures: 3 and 3.5 for A, 2020, 5 and 2.5 for A, 2021 and 8 and 6.5 for B, 2020.

script.vtl ⇩

DS_r := max ( DS_1 group all time_agg ( "A" ) );

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_2
A202033.500000
A202152.500000
B202086.500000

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"}
      ]
    }
  ]
}