IVariableStub.MatrixAggregator

Syntax

MatrixAggregator(DimInstance: IDimInstance): IBasicMatrixAggregator;

Parameters

DimInstance - data that must be aggregated.

Description

The MatrixAggregator property returns the object that contains properties and methods required for data aggregation.

Example

Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier containing a variable with the VAR identifier. The variable must contain several calendar levels.

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

Sub UserProc;
Var
    MB: IMetabase;
    MObj, VObj: IMetabaseObjectDescriptor;
    Stub: IVariableStub;
    Varable: IMsVariable;
    FactData: IDimInstance;
    BasicAggr: IBasicMatrixAggregator;
    Dim: IDimensionModel;
    Lvl: IDimLevels;
    LevAggr: IBasicMatrixLevelAggregator;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    MatrDS: IMatrixDataSource;
    DimSS: IDimSelectionSet;
    Matr, Matr1: IMatrix;
    Iter, Iter1: IMatrixIterator;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    MObj := MB.ItemById("CONT_MODEL");
    VObj := MB.ItemByIdNamespace("VAR", MObj.Key);
    Stub := VObj.Bind As IVariableStub;
    Varable := VObj.Bind As IMsVariable;
    FactData := (Stub.Calendar As IMetabaseObject).Open(NullAs IDimInstance;
    BasicAggr := Stub.MatrixAggregator(FactData);
//For calendar dimension
    Dim := Stub.Calendar;
    Lvl := Dim.Levels;
    BasicAggr.Dimension := Dim;
    LevAggr := BasicAggr.LevelAggregation(Lvl.Item(Lvl.Count - 2));
    LevAggr.Operation := BasicAggregatorOperation.ActualMean;
    LevAggr.Include(Lvl.Item(Lvl.Count - 1)) := True;
//Collecting source matrix with data
    CubeInst := (Varable.Cube As IMetabaseObject).Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    MatrDS := Dest As IMatrixDataSource;
    DimSS := MatrDS.CreateDimSelectionSet;
    For i := 0 To DimSS.Count - 1 Do
        DimSS.Item(i).SelectAll;
    End For;
    Matr := MatrDS.Execute(DimSS);
//Perform aggregation by calendar dimension
    Matr1 := BasicAggr.Execute(0, Matr);
    Iter := Matr.CreateIterator;
    Iter1 := Matr1.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Iter1.Move(IteratorDirection.First);
    Debug.WriteLine("Matrix of source data");
    While Iter.Valid Do
        Debug.WriteLine(Iter.Value);
        Iter.Move(IteratorDirection.Next);
    End While;
    Debug.WriteLine(Matrix of aggregated data);
    While Iter1.Valid Do
        Debug.WriteLine(Iter1.Value);
        Iter1.Move(IteratorDirection.Next);
    End While;
End Sub UserProc;

After executing the example a data aggregator is created for the variable. Aggregation is executed by the elements of calendar dimension from the last to the last by one level, using the method of actual mean. Aggregated data is calculated after the setup. The source matrix and aggregated data matrix are displayed in the development environment console.

See also:

IVariableStub