← calc operator page · clause/calc/measure_explicit/attribute_changed_to_measure

Attribute changed to measure 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

calc measure At_1 := At_1: the Attribute At_1 recalculated with its own values and the role measure.

Manual:

Calculation of a Component: "It is possible to specify the role of the calculated Component among measure, identifier, attribute, or viral attribute, therefore the calc clause can be used also to change the role of a Component when possible."

Expected:

At_1 keeps its name and its values, 5 and 6, as a Measure: the result has two Measures, Me_1 and At_1.

script.vtl ⇩

DS_r := DS_1 [ calc measure At_1 := At_1 ];

input/DS_1.csv ⇩

Id_1Me_1At_1
1105
2206

input/DS_1.json ⇩

{
  "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": "Integer", "role": "Attribute", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1At_1
1105
2206

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"},
        {"name": "At_1", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}