IMsDetermAggregationTransform.AggregationExpr

Syntax

AggregationExpr: IExpression;

Description

The AggregationExpr property returns the expression of aggregation.

Comments

To set expression used for aggregation threshold calculation, use the IMsDetermAggregationTransform.CompositionRelevanceExpr property.

Example

Executing the example requires that the repository contains a modeling parameter with the MS identifier containing the Aggregation (basic) model with the MODEL_DETERM_AGGR identifier.

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

Sub UserProc;
Var
    mb: IMetabase;
    ModelCont: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    Formula: IMsFormula;
    DetermAggregation: IMsDetermAggregationTransform;
    TermInfo: IMsFormulaTermInfo;
    Stub: IVariableStub;
    TransformVar: IMsFormulaTransformVariable;
    SelectionFact: IDimSelectionSetFactory;
    SelectionAgr, SelectionW, SelectionRel: IDimSelectionSet;
    i: Integer;
    DimI: IDimInstance;
    Slice: IMsFormulaTransformSlice;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container
    ModelCont := mb.ItemById("MS");
    // Get model
    Model := mb.ItemByIdNamespace("MODEL_DETERM_AGGR", ModelCont.Key).Edit As IMsModel;
    // Get model parameters
    Transform := Model.Transform;
    Formula := Transform.FormulaItem(0);
    Formula.Kind := MsFormulaKind.DetermAggregation;
    DetermAggregation := Formula.Method As IMsDetermAggregationTransform;
    // Create selections to generate aggregation expressions
    Stub := (ModelCont.Bind As IMsModelSpace).DefaultObject.Bind As IVariableStub;
    SelectionFact := New DimSelectionSetFactory.Create;
    SelectionAgr := SelectionFact.CreateDimSelectionSet;
    SelectionW := SelectionFact.CreateDimSelectionSet;
    SelectionRel := SelectionFact.CreateDimSelectionSet;
    For i := 0 To Stub.DimensionCount - 1 Do
        DimI := (Stub.Dimension(i) As IMetabaseObject).Open(NullAs IDimInstance;
        SelectionAgr.Add(DimI);
        SelectionAgr.Item(i).SelectElement(i, False);
        SelectionW.Add(DimI);
        SelectionW.Item(i).SelectElement(i + 1False);
        SelectionRel.Add(DimI);
        SelectionRel.Item(i).SelectElement(i + 2False);
    End For;
    // Set aggregation expression
    TermInfo := Transform.CreateTermInfo;
    TransformVar := Transform.Inputs.Add(Stub);
    Slice := TransformVar.Slices.Add(SelectionAgr);
    TermInfo.Slice := Slice;
    DetermAggregation.AggregationExpr.AsString := TermInfo.TermInnerText;
    // Set expression of weights
    TransformVar := Transform.Inputs.Add(Stub);
    Slice := TransformVar.Slices.Add(SelectionW);
    TermInfo.Slice := Slice;
    DetermAggregation.WeightsExpr.AsString := TermInfo.TermInnerText;
    // Set expression to calculate aggregation threshold
    TransformVar := Transform.Inputs.Add(Stub);
    Slice := TransformVar.Slices.Add(SelectionRel);
    TermInfo.Slice := Slice;
    DetermAggregation.CompositionRelevanceExpr.AsString := TermInfo.TermInnerText;
    // Save model
    (Model As IMetabaseObject).Save;
    // Display name of output variable
    Debug.WriteLine("Output variable: " + DetermAggregation.Result.TermToText);
End Sub UserProc;

After executing the example aggregation expression, expression for calculating the aggregation threshold and expression for setting aggregation weights are set for the model. The console window displays output variable name.

See also:

IMsDetermAggregationTransform