← nvl operator page · conditional/nvl/comp_sc/null_replaced_by_zero

Null replaced by zero 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

nvl ( Me_1, 0 ) inside calc: a component and a scalar. The new measure Me_2 is added and Me_1 is left as it is.

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_2 is 10, 0 and 30: the null Me_1 of id 2 becomes 0 in Me_2 and stays null in Me_1.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1
110
2
330

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
11010
20
33030

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