IMsParametrizedDimension.Aggregation

Syntax

Aggregation: IMsParametrizedDimensionAggregation;

Description

The Aggregation property returns settings of aggregation for parametrized dimension.

Comments

By default parametrized dimension is not aggregated.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier that contains a metamodel with the METAMODEL_PARAMAGGREGATION identifier. This model must calculate an equation with the MODEL_PARAMAGGREGATION identifier containing one or several factors. The modeling container data source must contain an attribute with the CITY identifier that is a link to a dictionary containing a logical attribute with the ISCAPITAL identifier.

Add links to the Cubes, Dal, Dimensions, Matrix, Metabase, Ms, Rds, Transform system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    MsKey: Integer;
    TSDB: IRubricator;
    MS: IMsModelSpace;
    Attributes: IMetaAttributes;
    Dict: IMetabaseObjectDescriptor;
    MetaModel: IMsMetaModel;
    MParams: IMsModelParams;
    CParam: IMsModelParam;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    Inputs: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    dimInstC: IDimInstance;
    dimSelC: IDimSelection;
    paramDim: IMsParametrizedDimensions;
    paramD: IMsParametrizedDimension;
    Aggregation: IMsParametrizedDimensionAggregation;
    CAdvFilter: IMsDimIteratorAdvancedFilter;
    i: Integer;
    CAdvFilterCond: IMsDimIteratorAdvancedFilterCondition;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container key
    MsKey := mb.GetObjectKeyById("MS");
    // Get modeling container
    MS := mb.Item(MsKey).Bind As IMsModelSpace;
    // Get time series database,
    // which is a data source for modeling container
    TSDB := MS.DefaultObject.Bind As IRubricator;
    // Get series attributes
    Attributes := TSDB.Facts.Attributes;
    // Get dictionary which is the base for the CITY attribute
    Dict := Attributes.FindById("CITY").ValuesObject;
    // Get metamodel
    MetaModel := mb.ItemByIdNamespace("METAMODEL_PARAMAGGREGATION", MsKey).Edit As IMsMetaModel;
    // Get and clear metamodel parameters
    MParams := MetaModel.Params;
    MParams.Clear;
    // Add a parameter based on  dictionary of the CITY attribute
    CParam := MParams.Add;
    CParam.DataType := DbDataType.Integer;
    CParam.Hidden := True;
    CParam.Id := "CITY";
    CParam.Name := "City";
    CParam.LinkedObject := Dict;
    CParam.ParamType := TsParamType.Selection;
    dimInstC := Dict.Open(NullAs IDimInstance;
    dimSelC := dimInstC.CreateSelection;
    dimSelC.SelectElement(1False);
    CParam.DefaultValue := dimSelC;
    // Save metamodel
    (MetaModel As IMetabaseObject).Save;
    // Get model
    Model := mb.ItemByIdNamespace("MODEL_PARAMAGGREGATION", MsKey).Edit As IMsModel;
    // Get model calculation parameters
    Transform := Model.Transform;
    // Get model factor
    Inputs := Transform.Inputs.Item(0);
    // Determine that the attribute value based on the CITY attribute dictionary
    // is determined by metamodel parameter
    Slice := Inputs.Slices.Item(0);
    paramDim := Slice.ParametrizedDimensions;
    paramD := paramDim.FindById(dimInstC.Ident);
    paramD.ParamAttributes.Parameter := CParam;
    // Get aggregation parameters
    Aggregation := paramD.Aggregation;
    // Determine that aggregation is executed by hierarchy
    Aggregation.ByHierarchy := True;
    // Set aggregation type
    Aggregation.Type := BasicAggregatorOperation.Sum;
    // Get advanced filter and clear all conditions
    CAdvFilter := Aggregation.AdvancedFilter;
    CAdvFilter.Clear;
    // Add advanced filtering condition
    CAdvFilterCond := CAdvFilter.Add;
    // Set filtered attribute
    CAdvFilterCond.Attribute := dimInstC.Attributes.FindById("ISCAPITAL").Attribute;
    // Set comparison operator
    CAdvFilterCond.Operator_ := MsAdvancedFilterConditionOperator.Equal;
    // Set required attribute value
    CAdvFilterCond.Value := True;
    // Save model 
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example a parametrized dimension is set for the first factor, in which aggregation is set up.

See also:

IMsParametrizedDimension