← sum operator page · aggregate/sum/ds_having/one_measure

One measure 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

sum with the having of Two measures, on a single-measure operand: the shared input without Me_2.

Manual:

Aggregate invocation: "only groups for which havingCondition evaluates to true appear in the result"; the page does not restrict having to single-measure operands.

Expected:

sum ( Me_1 ) > 11 holds for B only, which is kept with Me_1 = 12.

script.vtl ⇩

DS_r := sum ( DS_1 group by Id_1 having sum ( Me_1 ) > 11 );

input/DS_1.csv ⇩

Id_1Id_2Me_1
A2020Q13
A2020Q21
A2021Q15
A2021Q21
B2020Q14
B2020Q28

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

expected/DS_r.csv ⇩

Id_1Me_1
B12

expected/DS_r.json ⇩

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