← nvl operator page · conditional/nvl/comp_comp/second_component_fills_nulls

Second component fills nulls 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

nvl ( Me_1, Me_2 ) inside calc: two components of the same data set, with a null Me_1 and, in one data point, a null Me_2 as well.

Manual:

Nvl: "The operator nvl returns the value from op2 when the value from op1 is null, otherwise it returns the value from op1."

Expected:

Me_3 is 10, 200 and null: Me_1 is kept where it is not null; where it is null the result is Me_2, which is null at id 3.

script.vtl ⇩

DS_r := DS_1[calc Me_3 := nvl ( Me_1, Me_2 )];

input/DS_1.csv ⇩

Id_1Me_1Me_2
110100
2200
3

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},
        {"name": "Me_2", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2Me_3
11010010
2200200
3

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"},
        {"name": "Me_3", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}