IBasicMatrixAggregator.PutResultsToSourceMatrix

Syntax

PutResultsToSourceMatrix: Boolean;

Description

The PutResultsToSourceMatrix property determines a method for saving data aggregation result.

Comments

Available values:

To calculate aggregated data, use the IMatrixAggregatorModel.Execute method. The matrix with source data is sent by means of the Source parameter.

Example

Executing the example requires that repository contains a standard cube with the CUBE identifier. The cube should contain at least two dimensions.

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

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Destination: ICubeInstanceDestination;
    Man: IMatrixAggregatorManager;
    BasicAggr: IBasicMatrixAggregator;
    Dims: ICubeInstanceDimensions;
    Dim: IDimensionModel;
    Lvls: IDimLevels;
    LevAggr: IBasicMatrixLevelAggregator;
    MatrDS: IMatrixDataSource;
    DimSS: IDimSelectionSet;
    Matr, MatrAggr: IMatrix;
    Iter: IMatrixIterator;
    i: Integer;
Begin
    // Get the current repository
    MB := MetabaseClass.Active;
    // Get opened cube instance
    CubeInst := MB.ItemById("CUBE").Open(NullAs ICubeInstance;
    // Get cube display version set by default
    Destination := CubeInst.Destinations.DefaultDestination;
    // Create and set up data aggregator
    Man := New MatrixAggregatorManager.Create As IMatrixAggregatorManager;
    BasicAggr := Man.CreateAggregator("BasicMatrixAggregator"As IBasicMatrixAggregator;
    BasicAggr.PutResultsToSourceMatrix := True;
    // Get cube dimensions
    Dims := Destination.Dimensions;
    // Select the second dimension to set up aggregation parameters
    Debug.WriteLine("Aggregation parameters are set up for the dimension: " + Dims.Item(1).Name);
    // Get second dimension structure
    Dim := Dims.Item(1).Dimension;
    // Get dimension levels
    Lvls := Dim.Levels;
    BasicAggr.Dimension := Dim;
    // Set consumer level, source level and aggregation method - Sum
    LevAggr := BasicAggr.LevelAggregation(Lvls.Item(Lvls.Count - 2));
    LevAggr.Operation := BasicAggregatorOperation.Sum;
    LevAggr.Include(Lvls.Item(Lvls.Count - 1)) := True;
    // Set selection of the first element in the first dimension
    MatrDS := Destination As IMatrixDataSource;
    DimSS := MatrDS.CreateDimSelectionSet;
    DimSS.Item(0).SelectElement(0True);
    // Set full selection for the rest of dimensions
    For i := 1 To DimSS.Count - 1 Do
        DimSS.Item(i).SelectAll;
    End For;
    // Calculate matrix according to the specified selection
    Matr := MatrDS.Execute(DimSS);
    // Get matrix with source data
    Iter := Matr.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Debug.WriteLine("Source data:");
    While Iter.Valid Do
        Debug.WriteLine(Iter.Value + ": " + Iter.CoordsAsString);
        Iter.Move(IteratorDirection.Next);
    End While;
    Debug.WriteLine("");
    // Calculate aggregated data
    MatrAggr := BasicAggr.Execute(1, Matr);
    // Get matrix with aggregated and source data
    Iter := MatrAggr.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Debug.WriteLine("Aggregated and source data:");
    While Iter.Valid Do
        Debug.WriteLine(Iter.Value + ": " + Iter.CoordsAsString);
        Iter.Move(IteratorDirection.Next);
    End While;
End Sub UserProc;

After executing the operations a cube data aggregator is created. Aggregation will be executed by elements from the second to the first dimension level with the use of the Sum method for calculating basic aggregation mechanism. After the setup is complete, aggregated data is calculated. Source data matrix and aggregated data matrix with source one will be displayed in the console. For example:

Aggregation parameters are set up for the dimension: Dictionary 1

Source data:

1: 0 0 0

2: 0 2 0

3: 0 4 0

4: 0 0 1

5: 0 2 1

6: 0 4 1

7: 0 0 2

8: 0 2 2

9: 0 4 2

1: 0 1 0

1: 0 1 1

1: 0 1 2

1: 0 3 0

1: 0 3 1

1: 0 3 2

Aggregated data and source data:

2: 0 0 0

3: 0 2 0

3: 0 4 0

5: 0 0 1

6: 0 2 1

6: 0 4 1

8: 0 0 2

9: 0 2 2

9: 0 4 2

1: 0 1 0

1: 0 1 1

1: 0 1 2

1: 0 3 0

1: 0 3 1

1: 0 3 2

If the IBasicMatrixAggregator.PutResultsToSourceMatrix property is set to False, the second matrix will contain only aggregated data:

Aggregated data:

3: 0 2 0

2: 0 0 0

6: 0 2 1

5: 0 0 1

9: 0 2 2

8: 0 0 2

See also:

IBasicMatrixAggregator