IStandardCubeServerAggregationDimension.Position

Syntax

Position: Integer;

Description

The Position property determines position of the dimension in a group.

Comments

Numbering of positions in group is continuous and starts with zero.

Example

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

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

Sub UserProc;
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(NullAs 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;
    // Aggregation calculation
    Matr := Aggregator.Execute(DimSS);

    // Display 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 UserProc;

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:

IStandardCubeServerAggregationDimension