← case operator page · conditional/case/ds_multi_when/overlapping_named_conditions

Overlapping named conditions 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the two overlapping conditions of "Overlapping inline conditions", named: DS_c1 := DS_1 > 20 and DS_c2 := DS_1 > 10. The example shows only the order in which they are tried, and does not depend on how an engine handles an inline condition.

Manual:

Case: at data set level the operator "returns the Data Point from the thenOperand when the first Data Point of condition having the same Identifiers’ values evaluates to true; returns the Data Point from elseOperand if none of the when conditions evaluates to true".

Expected:

(1, 5), (2, 2) and (3, 300): id 3 meets both conditions, and the first wins, so DS_2's 300, not DS_3's 3. No recorded team decision applies, so the expected output follows the manual's "first".

script.vtl ⇩

DS_c1 := DS_1 > 20;
DS_c2 := DS_1 > 10;
DS_r := case when DS_c1 then DS_2 when DS_c2 then DS_3 else DS_1;

input/DS_1.csv ⇩

Id_1Me_1
15
215
325

input/DS_1.json ⇩

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

input/DS_2.csv ⇩

Id_1Me_1
1100
2200
3300

input/DS_2.json ⇩

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

input/DS_3.csv ⇩

Id_1Me_1
11
22
33

input/DS_3.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1
15
22
3300

expected/DS_r.json ⇩

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