← calc operator page · clause/calc/measure_default/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc Me_1 := Me_1 * 2 with no role, on the existing measure Me_1.

Manual:

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".

Expected:

Me_1 stays a Measure, with its values doubled: 40, 4 and 4.

script.vtl ⇩

DS_r := DS_1 [ calc Me_1:= Me_1 * 2 ];

input/DS_1.csv ⇩

Id_1Id_2Id_3Me_1
1ACA20
1BCA2
2ACA2

input/DS_1.json ⇩

{
  "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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Id_3Me_1
1ACA40
1BCA4
2ACA4

expected/DS_r.json ⇩

{
  "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"}
      ]
    }
  ]
}