← case operator page · conditional/case/comp_multi_when/overlapping_descending_thresholds

Overlapping descending thresholds 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

case when Me_1 > 10 then 10 when Me_1 > 1 then 1 else 0 inside calc: two conditions that overlap, the usual descending-threshold form, to tell the first true when from the last.

Manual:

Case: "The case operator returns the first thenOperand whose corresponding condition evaluates to true, elseOperand if none of the when conditions evaluates to true." At Component level "the operation is applied for each Data Point of the unique input Data Set".

Expected:

Me_2 is 0, 1 and 10: for 15 both conditions hold, and the first gives 10, not 1. No recorded team decision applies, so the expected output follows the manual's "first".

script.vtl ⇩

DS_r := DS_1[calc Me_2 := case when Me_1 > 10 then 10 when Me_1 > 1 then 1 else 0];

input/DS_1.csv ⇩

Id_1Me_1
10
25
315

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
100
251
31510

expected/DS_r.json ⇩

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