Skip to main content

VTL

Documentation

The VTL documentation is available on the official SDMX web site:

Datasets

VTL datasets must be described by metadata. The different columns have a type and a role.

By default, in Trevas, a column without type or role will be assigned a string type and a measure role.

The user will then be able to mutate these attributes in the script, in particular via the calc and cast operators.

Simple example

Considering ds_1 defined as follows:

id_1id_2me_1
typestringstringstring
roleidentifieridentifiermeasure
id_1id_2me_1
"75001""75""10"
"75002""75""100"
"70001""70""5"
"70002""70""70"

To obbtain the sum of me_1 by id_2, only id_2 has to have the identifier role and me_1 has to have the integer type. The following scipt is thus applied:

ds_2 := ds_1[calc measure id_2 := id_2, me_1 := cast(me_1, integer)];

ds_2 is then:

id_1id_2me_1
typestringstringinteger
rolemeasureidentifiermeasure
id_1id_2me_1
"75001""75"10
"75002""75"100
"70001""70"5
"70002""70"70

It is now possible to apply the aggr operator:

ds_3 := ds_2[aggr sum_me_1 := sum(me_1) group by id_2];

To obtain ds_3:

id_2sum_me_1
typestringinteger
roleidentifiermeasure
id_2me_1
"75"110
"70"75