← calc operator page · clause/calc/measure_default/manual_ex_1
pandas ✅ · DuckDB ✅
calc Me_1 := Me_1 * 2 with no role, on the existing measure Me_1.
Calculation of a Component, Example 1, output verbatim: "When the role is omitted, the following rule is applied: 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".
Me_1 stays a Measure, with its values doubled: 40, 4 and 4.
DS_r := DS_1 [ calc Me_1:= Me_1 * 2 ];
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| 1 | A | CA | 20 |
| 1 | B | CA | 2 |
| 2 | A | CA | 2 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Id_3", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Id_3 | Me_1 |
|---|---|---|---|
| 1 | A | CA | 40 |
| 1 | B | CA | 4 |
| 2 | A | CA | 4 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Id_3", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}