IMatrixAggregatorModel.Execute

Syntax

Execute(DimIndex: Integer; Source: IMatrix): IMatrix;

Parameters

DimIndex. Index of the dimension, by which elements aggregation is executed.

Source. Matrix with source data, based on which aggregation is executed.

Description

The Execute method calculates aggregated data.

Example

Executing the example requires that the repository contains a cube with the CUBE identifier. There are two dimensions in the cube. The second dimension is a calendar one.

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Destination: ICubeInstanceDestination;
    Man: IMatrixAggregatorManager;
    Dim: IDimensionModel;
    Lvls: IDimLevels;
    BasicAggr: IBasicMatrixAggregator;
    LevAggr: IBasicMatrixLevelAggregator;
    MatrDS: IMatrixDataSource;
    DimSS: IDimSelectionSet;
    Matr, Matr1: IMatrix;
    Iter, Iter1: IMatrixIterator;
Begin
    MB := MetabaseClass.Active;
    CubeInst := MB.ItemById("CUBE").Open(NullAs ICubeInstance;
    Destination := CubeInst.Destinations.DefaultDestination;
    //Create and set up data aggregator
    Man := New MatrixAggregatorManager.Create As IMatrixAggregatorManager;
    BasicAggr := Man.CreateAggregator("BasicMatrixAggregator"As IBasicMatrixAggregator;
    //Second dimension - calendar
    Dim := Destination.Dimensions.Item(1).Dimension;
    Lvls := Dim.Levels;
    BasicAggr.Dimension := Dim;
    LevAggr := BasicAggr.LevelAggregation(Lvls.Item(Lvls.Count - 2));
    LevAggr.Operation := BasicAggregatorOperation.ActualMean;
    LevAggr.Include(Lvls.Item(Lvls.Count - 1)) := True;
    //Get source matrix with data
    MatrDS := Destination As IMatrixDataSource;
    DimSS := MatrDS.CreateDimSelectionSet;
    //First element in the first dimension
    DimSS.Item(0).SelectElement(0False);
    //All elements in calendar dimension
    DimSS.Item(1).SelectAll;
    //Get source matrix with data
    Matr := MatrDS.Execute(DimSS);
    //Get aggregated data by calendar dimension
    Matr1 := BasicAggr.Execute(1, Matr);
    //View results
    Iter := Matr.CreateIterator;
    Iter1 := Matr1.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Iter1.Move(IteratorDirection.First);
    Debug.WriteLine("Source data matrix");
    While Iter.Valid Do
        Debug.WriteLine(Iter.Value);
        Iter.Move(IteratorDirection.Next);
    End While;
    Debug.WriteLine("Aggregated data matrix");
    While Iter1.Valid Do
        Debug.WriteLine(Iter1.Value);
        Iter1.Move(IteratorDirection.Next);
    End While;
End Sub UserProc;

After executing the example a new data aggregator is created for a cube. Aggregation is performed by elements of a calendar dimension from the last to the next to last level using the actual mean method. Aggregated data is calculated after the setup is complete. Source matrix and aggregated data matrix are displayed in the development environment console.

See also:

IMatrixAggregatorModel