IAggregationInfoItem.Item

Syntax

Item(Index: Integer): IAggrDestCell;

Parameters

Index. Index of the element, in which aggregation was executed.

Description

The Item property returns the aggregated element.

Example

Executing the example requires that repository contains a standard cube with the CUBE identifier. The cube should contain at least two dimensions. The first dimension - MDM dictionary containing with hierarchical element structure and two levels. Cube facts should be added locally without the use of existing dictionary.

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;
     MatrixAggrInfo: IMatrixWithAggregationInfo;
     i, j: Integer;
     AggrInfo: IAggregationInfoItem;
     AggrInfoItem: IAggrDestCell;
     AggrSource: IAggrSourceCell;
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;
    // Get cube dimensions
    Dims := Destination.Dimensions;
    // 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);
    // Calculate aggregated data
    MatrixAggrInfo := BasicAggr.ExecuteWithAggregationInfo(1, Matr, Null);
    // Get matrix with aggregated data
    MatrAggr := MatrixAggrInfo.Matrix;
    Iter := MatrAggr.CreateIterator;
    Iter.Move(IteratorDirection.First);
    Debug.WriteLine("Aggregated data:");
    While Iter.Valid Do
        Debug.Write(Iter.Value + " ");
        Iter.Move(IteratorDirection.Next);
    End While;
    Debug.WriteLine("");
    // Get information about aggregation and source element values
    AggrInfo := MatrixAggrInfo.Item;
    For i := 0 To AggrInfo.Count - 1 Do
        Debug.WriteLine((i+1).ToString + " aggregated element:");
        AggrInfoItem := AggrInfo.Item(i);
        Debug.WriteLine("- calculation method: " + AggrInfoItem.Operation.ToString);
        Debug.WriteLine("- number of source elements: " + AggrInfoItem.Count.ToString);
        Debug.Write("- source values: ");
        For j := 0 To AggrInfoItem.Count - 1 Do
            AggrSource := AggrInfoItem.Item(j);
            Debug.Write(AggrSource.Value);
            Debug.Write(" (coordinate: " + AggrSource.Coord.Item(0).ToString + ", " + AggrSource.Coord.Item(1).ToString + "); ");
        End For;
        Debug.WriteLine("");
    End For;
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. Aggregated data and information about source element values will be displayed in the console. For example:

Aggregated data:

4 3 7 6 10 9

The first aggregated element:

- calculation method: 1

- number of source elements: 2

- source values: 2 (coordinate: 0, 0); 1 (coordinate: 0, 1).

The second aggregated element:

- calculation method: 1

- number of source elements: 2

- source values: 3 (coordinate: 0, 2); 1 (coordinate: 0, 3).

The third aggregated element:

- calculation method: 1

- number of source elements: 2

- source values: 5 (coordinate: 0, 0); 1 (coordinate: 0, 1).

The fourth aggregated element:

- calculation method: 1

- number of source elements: 2

- source values: 6 (coordinate: 0, 2); 1 (coordinate: 0, 3).

The fifth aggregated element:

- calculation method: 1

- number of source elements: 2

- source values: 8 (coordinates: 0, 0); 1 (coordinate: 0, 1).

The sixth aggregated element:

- calculation method: 1

- number of source elements: 2

- source values: 9 (coordinate: 0, 2); 1 (coordinate: 0, 3).

See also:

IAggregationInfoItem