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.

Comments

To determine a method for saving data aggregation result, use the IBasicMatrixAggregator.PutResultsToSourceMatrix property.

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.

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

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;
    // Select the second dimension that is 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;
    MatrDS := Destination As IMatrixDataSource;
    DimSS := MatrDS.CreateDimSelectionSet;
    // Set selection of the first element in the first dimension
    DimSS.Item(0).SelectElement(0False);
    // Set full selection for 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);
    // Display data aggregation result
    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. The source matrix and the matrix with aggregated data will be displayed in the console.

See also:

IMatrixAggregatorModel