← case operator page · conditional/case/ds_multi_when/overlapping_inline_conditions
pandas ✅ · DuckDB ✅
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.
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".
(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".
DS_r := case when DS_1 > 20 then DS_2 when DS_1 > 10 then DS_3 else DS_1;
| Id_1 | Me_1 |
|---|---|
| 1 | 5 |
| 2 | 15 |
| 3 | 25 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
{
"datasets": [
{
"name": "DS_2",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
{
"datasets": [
{
"name": "DS_3",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 5 |
| 2 | 2 |
| 3 | 300 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}