← count operator page · aggregate/count/ds_having/two_measures

Two measures 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

count with having, over the two measures of the shared input.

Manual:

Aggregate invocation: the havingCondition "must invoke aggregate operators", and "only groups for which havingCondition evaluates to true appear in the result". The condition aggregates Me_1 only, where the manual and the reading of #1119 agree.

Expected:

count ( Me_1 ) > 2 is 4 for A and 2 for B, so only A is kept, with int_var = 4.

Team decision:

#1049: over a data set, count gives one Integer measure int_var whatever the measures of the operand, 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 by Id_1 having count ( Me_1 ) > 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_1int_var
A4

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier"},
        {"name": "int_var", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}