← calc operator page · clause/calc/measure_default/existing_attribute_keeps_role
pandas ✅ · DuckDB ✅
calc At_1 := "X" with no role: At_1 is an Attribute of DS_1.
Calculation of a Component: "if the component exists in the operand Data Set then it maintains its role", and "If the Calculated component is a Measure or an Attribute that already exists in the input Data Set, the calculated values overwrite the original values".
At_1 stays an Attribute, with X on every data point; Id_1 and Me_1 are unchanged.
DS_r := DS_1 [ calc At_1 := "X" ];
| Id_1 | Me_1 | At_1 |
|---|---|---|
| 1 | 10 | A |
| 2 | 20 | B |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "At_1", "type": "String", "role": "Attribute", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | At_1 |
|---|---|---|
| 1 | 10 | X |
| 2 | 20 | X |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"},
{"name": "At_1", "type": "String", "role": "Attribute"}
]
}
]
}