← less operator page · comparison/less/comp_comp/two_measures_and_null
pandas ✅ · DuckDB ✅
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.
Less than: "The operator < returns true if left is smaller 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).
Me_3 is a new boolean measure: true, false, false 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.
DS_r := DS_1 [ calc Me_3 := Me_1 < Me_2 ];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 1 | 3 |
| 2 | 2 | 2 |
| 3 | 3 | 1 |
| 4 | 4 |
{
"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}
]
}
]
}
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 1 | 3 | true |
| 2 | 2 | 2 | false |
| 3 | 3 | 1 | false |
| 4 | 4 |
{
"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"}
]
}
]
}