HierarchyParamAttributes: IMsModelParamAttributes;
The HierarchyParamAttributes property returns settings for binding alternative hierarchy to parameter attributes.
Binding to parameter attribute allows for dynamically change the alternative hierarchy used in calculation. The specified attribute should be an integer and store keys of the dictionaries that are alternative hierarchies of the dimension, for which filter is to be set up.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier and a standard cube with the CUBE identifier. An aggregation block should be created in the calculation algorithm; the cube should contain dimensions with the PROCESS and VERSION identifiers. Alternative hierarchies should be set up for the PROCESS dimension. The structure of the VERSION dimension has the HKEY attribute containing keys of alternative hierarchies of the PROCESS dimension.
Add a link to the Calculation Algorithm Core user assembly contained in the Calculation Algorithms component, and links to the Algo, Cubes, Dimensions, Metabase, Ms, Transform system assemblies.
Add links to the system assemblies:
Sub UserProc;
Var
MB: IMetabase;
MObj, Dim: IMetabaseObjectDescriptor;
Algo, Aggr: ICalcObject;
List: ICalcObjectsList;
CalcAlgo: ICalcAlgorithm;
Block: ICalcAggr;
Stub: IVariableStub;
StandCub: IStandardCube;
Params: IMsModelParams;
Param: IMsModelParam;
DimInst: IDimInstance;
Filter: IMsAggregationFilter;
HieParamAttrs: IMsModelParamAttributes;
Begin
MB := MetabaseClass.Active;
// Get calculation algorithm
MObj := MB.ItemById("ALGORITHM");
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
CalcAlgo := Algo As ICalcAlgorithm;
// Get list of calculation algorithm objects
List := CalcAlgo.Items;
// Get aggregation block with the 0 index
Aggr := List.Item(0);
Block := Aggr As ICalcAggr;
// Get cube
StandCub := MB.ItemById("CUBE").Edit As IStandardCube;
Stub := StandCub As IVariableStub;
// Set cube as a data consumer
Block.Stub := Stub;
// Add parameter
Params := Block.Params;
Param := Params.Add;
Param.Id := "Version";
Param.Name := "Version";
Param.ParamType := TsParamType.Selection;
Param.LinkedStub := Stub;
Dim := MB.ItemById("VERSION");
Param.LinkedObject := Dim;
// Set up filtering for the specified dimension
DimInst := StandCub.Destinations.Item(0).Dimensions.FindById("PROCESS").OpenDimension;
Filter := Block.AggregatorFilter(DimInst);
HieParamAttrs := Filter.HierarchyParamAttributes;
HieParamAttrs.Parameter := Param;
HieParamAttrs.Attributes.Add((Dim.Open(Null) As IDimInstance).Attributes.FindById("HKEY").Attribute);
// Save changes in aggregation block
Block.SaveObject;
End Sub UserProc;
After executing the example, calculation algorithm aggregation block settings will be changed:
A parameter based on the VERSION dictionary is created.
The CUBE cube is set as a data consumer.
Dynamic control of alternative hierarchy is set up for the PROCESS dimension via values of the HKEY attribute of the VERSION dimension.
See also: