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

Quarters to years 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

count with the deprecated group all time_agg ( "A" ), which turns each quarter of Id_2 into its year.

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 int_var = 2 for A, 2020, A, 2021 and B, 2020.

Team decision:

#1049: over a data set, count gives one Integer measure int_var whatever the operand's measures, and ignores the data points whose measures are all null. With two measures, this settles the conflict between the count page's int_var and the Aggregate invocation's "the resulting Data Set has the same Measures as the operand".

script.vtl ⇩

DS_r := count ( 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_2int_var
A20202
A20212
B20202

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": "int_var", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}