IMsAggregationFilter.HierarchyKey

Syntax

HierarchyKey: Integer;

Description

The HierarchyKey property determines a key of aggregation by levels of alternative hierarchy in the collection of dimension alternative hierarchies.

Comments

The collection of dimension alternative hierarchies is contained in the Alternative Hierarchies folder with alternative hierarchy levels available for the dimension, and is used to work with aggregation filter.

Example

Executing the example requires that the repository contains a table MDM dictionary with the RDS_DICT identifier, a modeling container with the CONT_MODEL identifier containing a modeling problem with the PROBLEM identifier. The model should contain a metamodel with the METAMODEL identifier, which calculation chain contains a matrix aggregation model with the MODEL identifier.

For the table MDM dictionary set up alternative hierarchy based on dictionaries and add an integer attribute with the HKEY identifier to use the alternative hierarchy.

Add links to the Dimensions, Metabase, Ms, Transform system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    RubrDescr, Descr: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Formula: IMsFormula;
    MA: IMsMatrixAggregationTransform;
    Filter: IMsAggregationFilter;
    MetaModel: IMsMetaModel;
    Param: IMsModelParam;
    Params: IMsModelParams;
    Dim: IDimInstance;
    Hierarchy: IDimHierarchy;
    Structure: IDimensionModel;
    Hierarchies: IDimHierarchies;
    HieKey: Integer;
    Transform: IMsFormulaTransform;
    ParamAttr: IMsModelParamAttributes;
    Attr: IDimAttributeInstance;
    Attributes: IDimAttributesInstance;
    DimAttr: IDimAttribute;
Begin
    MB := MetabaseClass.Active;
    
// Get table MDM dictionary, which uses alternative hierarchy
    Dim := MB.ItemById("RDS_DICT").Open(NullAs IDimInstance;
    
// Get dictionary structure
    Structure := Dim.Dimension;
    
// Get collection of dictionary alternative hierarchies
    Hierarchies := Structure.Hierarchies;
    
// Get key of the first level of alternative hierarchy
    Hierarchy := Hierarchies.Item(0);
    HieKey := Hierarchy.Key;
    
// Get dictionary attribute used for alternative hierarchy
    Attributes := Dim.Attributes;
    Attr := Attributes.FindById(
"HKEY");
    DimAttr := Attr.Attribute;
    
// Get modeling container
    RubrDescr := MB.ItemById("CONT_MODEL");
    Descr := RubrDescr.EditDescriptor;
    
// Get metamodel
    MetaModel := MB.ItemByIdNamespace("METAMODEL", Descr.Key).Edit As IMsMetaModel;
    
// Create a metamodel parameter
    Params := MetaModel.Params;
    Param := Params.Add;
    Param.Id := 
"HIE";
    Param.Name := 
"Hierarchy";
    Param.ParamType := TsParamType.Hierarchy;
    
// Bind parameter to MDM dictionary
    Param.LinkedObject := Structure As IMetabaseObjectDescriptor;
    
// Save changes
    (MetaModel As IMetabaseObject).Save;
    
// Get matrix aggregation model
    Model := MB.ItemByIdNamespace("MODEL", Descr.Key).Edit As IMsModel;
    
// Get model calculation parameters
    Transform := Model.Transform;
    Formula := Transform.FormulaItem(
0);
    MA := Formula.Method 
As IMsMatrixAggregationTransform;
    
// Add and set up aggregation filter
    Filter := MA.Filter.Add(Structure);
    Filter.HierarchyKey := HieKey;
    ParamAttr := Filter.HierarchyParamAttributes;
    ParamAttr.Parameter := Param;
    ParamAttr.Attributes.Add(DimAttr);
    
// Save changes
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, the aggregation filter is set up for model parameter:

See also:

IMsAggregationFilter