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

Overlapping inline conditions 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

case when DS_1 > 20 then DS_2 when DS_1 > 10 then DS_3 else DS_1: two overlapping conditions written inline, on data sets, to see which true condition wins.

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 1 meets no condition, so it keeps DS_1; id 2 meets only the second, so it comes from DS_3; id 3 meets both, 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_r := case when DS_1 > 20 then DS_2 when DS_1 > 10 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"}
      ]
    }
  ]
}