← nvl operator page · conditional/nvl/ds_sc/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

nvl ( DS_1, 0 ) on a data set: each null measure value becomes 0.

Manual:

Nvl, Example 1, output verbatim: "The operator nvl returns the value from op2 when the value from op1 is null, otherwise it returns the value from op1." The page's TimePeriod type is written Time_Period, as vtlengine does.

Expected:

Me_1 is 0 for S and N, where it is null, and unchanged for the other four.

script.vtl ⇩

DS_r := nvl ( DS_1, 0 );

input/DS_1.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal11094850
2012GTotalTotal11123034
2012STotalTotal
2012MTotalTotal417546
2012FTotalTotal5401267
2012NTotalTotal

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3Id_4Me_1
2012BTotalTotal11094850
2012GTotalTotal11123034
2012STotalTotal0
2012MTotalTotal417546
2012FTotalTotal5401267
2012NTotalTotal0

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
        {"name": "Id_2", "type": "String", "role": "Identifier"},
        {"name": "Id_3", "type": "String", "role": "Identifier"},
        {"name": "Id_4", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}