← aggr operator page · clause/aggr/group_all/quarters_to_years

Quarters to years 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

aggr Me_1 := sum ( Me_1 ) group all time_agg ( "A" ), on the quarterly time_period identifier Id_1.

Manual:

Aggregation: group all "converts the values of an Identifier Component using conversionExpr and keeps all the resulting Identifiers". Time aggregation: in an aggregation "op must not be specified, and the source dataset must have exactly one Identifier of type time, date or time_period", and on time_period "the original period indicator is converted in the target one".

Expected:

The data points are grouped by the annual Id_1 and by Id_2: (2020A, A) = 1 + 2 = 3, (2021A, A) = 4 and (2020A, B) = 8, where Me_1 may be Integer or Number, by the integer rule of the Sum page. Aggregate invocation marks group all with "This option is deprecated"; the Aggregation page does not.

script.vtl ⇩

DS_r := DS_1 [ aggr Me_1 := sum ( Me_1 ) group all time_agg ( "A" ) ];

input/DS_1.csv ⇩

Id_1Id_2Me_1
2020Q1A1
2020Q2A2
2021Q1A4
2020Q1B8

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1
2020AA3
2021AA4
2020AB8

expected/DS_r.json ⇩

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