← greater operator page · comparison/greater/comp_comp/two_measures_and_null

Two measures and null 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

Me_1 > Me_2 inside calc: two measures of one data set, equal in one data point and with a null Me_2 in another.

Manual:

Greater than: "The operator > returns true if left is greater than right, false otherwise." A null operand gives a null result: "Whenever a null value is involved in a comparison (>, <, >=, <=, in, not in, between) the result of the comparison is null" (User Manual).

Expected:

Me_3 is a new boolean measure: false, false, true and null for ids 1 to 4; 2 > 2 is false, as > excludes the equal value, and id 4 compares 4 with a null; Me_1 and Me_2 are kept.

script.vtl ⇩

DS_r := DS_1 [ calc Me_3 := Me_1 > Me_2 ];

input/DS_1.csv ⇩

Id_1Me_1Me_2
113
222
331
44

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
113false
222false
331true
44

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": "Boolean", "role": "Measure"}
      ]
    }
  ]
}