← case operator page · conditional/case/sc_multi_when/both_conditions_true

Both conditions true 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

case when SC_1 > 10 then 10 when SC_1 > 1 then 1 else 0 with SC_1 = 15: two conditions that are both true, the usual descending-threshold form, to tell the first true when from the last. In the other examples of this form at most one condition is true.

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."

Expected:

SC_r = 10, an Integer: SC_1 > 10 and SC_1 > 1 are both true for 15, and the first gives 10, not the 1 of the second. No recorded team decision applies, so the expected output follows the manual's "first".

script.vtl ⇩

SC_r := case when SC_1 > 10 then 10 when SC_1 > 1 then 1 else 0;

input/scalars.csv ⇩

SC_1
15

input/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_1", "type": "Integer"}
  ]
}

expected/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_r", "type": "Integer", "value": "10"}
  ]
}