IMatrixAggregatorModel.Execute

Fore Syntax

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

Fore.NET Syntax

Execute(DimIndex: Integer; Source: Prognoz.Platform.Interop.Matrix.IMatrix): Prognoz.Platform.Interop.Matrix.IMatrix;

Parameters

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

Source. Matrix of data source, based on which aggregation is performed.

Description

The Execute method calculates aggregated data.

Fore Example

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

Sub AggregationData;
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_1").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 AggregationData;

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 finished. Source matrix and aggregated data matrix are displayed in the development environment console.

Fore.NET Example

Executing the example requires that the repository contains a cube with the Cube_1 identifier. There are two dimensions in the cube. The second dimension is a calendar one. This procedure is an entry point of the .NET assembly.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Destination: ICubeInstanceDestination;
    Man: MatrixAggregatorManager = New MatrixAggregatorManagerClass();
    Dim: IDimensionModel;
    Lvls: IDimLevels;
    BasicAggr: IBasicMatrixAggregator;
    LevAggr: IBasicMatrixLevelAggregator;
    MatrDS: IMatrixDataSource;
    DimSS: IDimSelectionSet;
    Matr, Matr1: IMatrix;
    Iter, Iter1: IMatrixIterator;
Begin
    MB := Params.Metabase;
    CubeInst := MB.ItemById["Cube_1"].Open(NullAs ICubeInstance;
    Destination := CubeInst.Destinations.DefaultDestination;
    //Set up data aggregator
    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.baoActualMean;
    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.itdFirst);
    Iter1.Move(IteratorDirection.itdFirst);
    System.Diagnostics.Debug.WriteLine("Source data matrix");
    While Iter.Valid Do
        System.Diagnostics.Debug.WriteLine(Iter.Value);
        Iter.Move(IteratorDirection.itdNext);
    End While;
    System.Diagnostics.Debug.WriteLine("Aggregated data matrix");
    While Iter1.Valid Do
        System.Diagnostics.Debug.WriteLine(Iter1.Value);
        Iter1.Move(IteratorDirection.itdNext);
    End While;
End Sub;

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 finished. Source matrix and aggregated data matrix are displayed in the development environment console.

See also:

IMatrixAggregatorModel