IStandardCubeServerAggregator.Execute

Syntax

Execute(Selection: IDimSelectionSet): IMatrix;

Parameters

Selection - selection of dimensions, by which calculation is executed.

Description

The Execute method calculates aggregation and returns the matrix with calculated data.

Comments

This matrix contains an additional dimension that contains totals of aggregation. A coordinate in additional dimension corresponds to aggregation index.

NOTE. The coordinate is -1 in the matrix of aggregation calculation for the dimensions, by which the Other aggregate is calculated (IStandardCubeServerAggregationDimension.Others).

Example

Executing the example requires that the repository contains a standard cube with the OBJ_CUBE identifier. This cube must contain two dimensions.

Sub Main;

Var

MB: IMetabase;

MObj: IMetabaseObject;

StandCub: IStandardCube;

CubeInst: ICubeInstance;

CubeStandInst: IStandardCubeInstance;

Aggregator: IStandardCubeServerAggregator;

StdDim: IStandardCubeDimension;

StdDims: IStandardCubeDimensions;

Aggregation: IStandardCubeServerAggregation;

FactDimension: IDimInstance;

Iter: IDimIterator;

DimsEx: IStandardCubeServerAggregationDimensionsEx;

AggDim: IStandardCubeServerAggregationDimension;

MatrDS: IMatrixDataSource;

DimSS: IDimSelectionSet;

Matr: IMatrix;

Coord: IMatrixCoord;

i: Integer;

MatrIter: IMatrixIterator;

s: String;

Begin

MB := MetabaseClass.Active;

MObj := MB.ItemById("OBJ_CUBE").Bind;

StandCub := MObj As IStandardCube;

CubeInst := MObj.Open(Null) As ICubeInstance;

CubeStandInst := CubeInst As IStandardCubeInstance;

StdDims := StandCub.Dimensions;

 

// Set up aggregation method

Aggregator := CubeStandInst.CreateAggregator;

FactDimension := StandCub.FactDimension.OpenDimension;

Iter := FactDimension.Elements.Elements.Iterator;

Iter.First;

While Iter.Next Do

Aggregation := Aggregator.Aggregations.Add;

Aggregation.AggregationType := CubeFactBindingAggregationType.Sum;

Aggregation.FactKey := FactDimension.Indexes.PrimaryIndex.IndexAttributesValues(Iter.Element);

End While;

 

// Determine dimensions for aggregation

DimsEx := Aggregator.Dimensions;

AggDim := DimsEx.Item(0);

AggDim.GroupIndex := 0;

AggDim.Position := 0;

AggDim.Others := True;

AggDim := DimsEx.Item(1);

AggDim.GroupIndex := 1;

AggDim.Position := 0;

AggDim.Totals := True;

 

// Selection for aggregation calculation

MatrDS := CubeInst.Destinations.DefaultDestination As IMatrixDataSource;

DimSS := MatrDS.CreateDimSelectionSet;

For i := 0 To DimSS.Count - 1 Do

DimSS.Item(i).SelectAll;

End For;

 

// Calculate aggregation

Matr := Aggregator.Execute(DimSS);

 

// Dsplay aggregation results

MatrIter := Matr.CreateIterator;

MatrIter.Move(IteratorDirection.First);

If MatrIter.Valid Then

For i := 0 To StdDims.Count - 1 Do

StdDim := StdDims.Item(i);

If StdDim.FactDimension Then

Debug.Write("Fact   ");

Else

Debug.Write(StdDim.OpenDimension.Name + "  ");

End If;

End For;

Debug.Write("Aggregation  ");

Debug.WriteLine("Value");

 

Coord := Matr.CreateCoord;

While MatrIter.Valid Do

MatrIter.PutCurrentPos(Coord);

s := "";

For i := 0 To Coord.Count - 1 Do

s := s + Coord.Item(i).ToString + "       ";

End For;

s := s + "= " + MatrIter.Value;

Debug.WriteLine(s);

MatrIter.Move(IteratorDirection.Next);

End While;

Else

Debug.WriteLine("No data");

End If;

End Sub Main;

After executing the example sum by dimensions is calculated for the cube facts. The calculation matrix is displayed in the console window.

View results

See also:

IStandardCubeServerAggregator