Skip to main content

Trevas - check_hierarchy

· 2 min read
Nicolas Laval
Making Sense - Developer

News

Trevas 1.1.0 includes hierarchical validation via operators define hierarchical ruleset and check_hierarchy.

Example

Input

ds1:

idMe
ABC12
A1
B10
C1
DEF100
E99
F1
HIJ100
H99
I0

VTL script

// Ensure ds1 metadata definition is good
ds1 := ds1[calc identifier id := id, Me := cast(Me, integer)];

// Define hierarchical ruleset
define hierarchical ruleset hr (variable rule Me) is
My_Rule : ABC = A + B + C errorcode "ABC is not sum of A,B,C" errorlevel 1;
DEF = D + E + F errorcode "DEF is not sum of D,E,F";
HIJ : HIJ = H + I - J errorcode "HIJ is not H + I - J" errorlevel 10
end hierarchical ruleset;

// Check hierarchy
ds_all := check_hierarchy(ds1, hr rule id all);
ds_all_measures := check_hierarchy(ds1, hr rule id always_null all_measures);
ds_invalid := check_hierarchy(ds1, hr rule id always_zero invalid);

Outputs

  • ds_all
idruleidbool_varerrorcodeerrorlevelimbalance
ABCMy_Ruletruenullnull0
  • ds_always_null_all_measures
idMeruleidbool_varerrorcodeerrorlevelimbalance
ABC12My_Ruletruenullnull0
DEF100hr_2nullnullnullnull
HIJ100HIJnullnullnullnull
  • ds_invalid
idMeruleiderrorcodeerrorlevelimbalance
HIJ100HIJHIJ is not H + I - J101