← length operator page · string/length/comp/manual_ex_2
pandas ✅ · DuckDB ✅
length(Me_1) inside calc, where the new measure Me_2 takes the length; one value is null.
String length, Example 2, output verbatim: "Returns the length of a string."
Me_2 is 5 for hello and null for the null Me_1; Me_1 is kept. A null operand gives a null result: "most of the scalar operations (arithmetic, logical, and others) return null when any of their arguments is null" (User Manual).
DS_r:= DS_1[calc Me_2:=length(Me_1)];
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| 1 | A | hello |
| 2 | B |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 1 | A | hello | 5 |
| 2 | B |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"},
{"name": "Me_2", "type": "Integer", "role": "Measure"}
]
}
]
}