IAdoMdExecuteDimSetup.Calculations

Syntax

Calculations: IAdoMdDimCalculations;

Description

The Calculations property returns collection of calculated dimension elements.

Example

Executing the example requires that the repository contains an ADOMD directory with the ADOMDTest identifier, this directory contains the ADOMD cube - SALES. The cube structure must have dimensions based on ADOMD dictionaries with the DATE and COUNTRY identifiers.

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICubeInstance;
    Dest: ICubeInstanceDestination;
    SelSet: IDimSelectionSet;
    Sel: IDimSelection;
    DimSetup: ICubeExecuteDimSetup;
    Calcs: IAdoMdDimCalculations;
    Calc: IAdoMdDimCalculation;
    Exec: ICubeInstanceDestinationExecutor;
    AdoExec: IAdoMdCubeExecutor;
    Mat: IMatrix;
Begin
    MB := MetabaseClass.Active;
    CubeInst := MB.ItemByIdNamespace("SALES", MB.GetObjectKeyById("ADOMDTest")).Open(NullAs ICubeInstance;
    Dest := CubeInst.Destinations.DefaultDestination;
    SelSet := Dest.CreateDimSelectionSet;
    //Set selections
    For Each Sel In SelSet Do
        If Sel.Dimension.Ident = "COUNTRY" Then
            DimSetup := CubeClass.SelectionSetup(Sel);
            If DimSetup <> Null Then
                DimSetup.GroupIndex := 2;
            End If;
            //Create a calculated element
            Calcs := (DimSetup.Extension As IAdoMdExecuteDimSetup).Calculations;
            Calc := Calcs.Add("");
            Calc.Element(Sel.Dimension) := Sel.LastDimElement;
            Calc.Expression := "SUM([DATE].[Year].Children)";
            //Full selection
            Sel.SelectAll;
        Elseif Sel.Dimension.Ident = "DATE" Then
            Sel.SelectElement(1False);
            DimSetup := CubeClass.SelectionSetup(Sel);
            If DimSetup <> Null Then
                DimSetup.GroupIndex := 1;
            End If;
        Else
            Sel.SelectElement(1False);
            DimSetup := CubeClass.SelectionSetup(Sel);
            If DimSetup <> Null Then
                DimSetup.GroupIndex := 0;
            End If;
        End If
    End For;
    //Calculation
    Exec := Dest.CreateExecutor;
    AdoExec := Exec As IAdoMdCubeExecutor;
    Exec.PrepareExecute(SelSet);
    Exec.PerformExecute;
    Mat := Exec.Matrix;
End Sub UserProc;

On executing the example a calculated element is added for the last element in the COUNTRY dimension. After this the cube is calculated, resulting matrix is available in the Mat variable.

See also:

IAdoMdExecuteDimSetup