ICalculatedCubeInstance.Apply

Syntax

Apply(App: ICubeSelectionControlApply): Boolean;

Parameters

Apply. Parameters of managing selection that must be applied.

Description

The Apply method applies selection control parameters.

Comments

The method returns True if selection use with specified parameters was successful, and False if selection cannot be used.

Example

Executing the example requires that the repository contains a calculated cube with the Calc_Cube identifier. This cube is based on the cube, which contains controlling and controlled dimensions. A controlling dimension is the dimension based on the Dim_1 dictionary.

Sub UserProc;
Var
    MB: IMetabase;
    CubeInst: ICalculatedCubeInstance;
    Source: ICubeInstanceSource;
    SelControl: ICubeSelectionControlApply;
    DimSS: IDimSelectionSet;
    Inst: IDimInstance;
Begin
    MB := MetabaseClass.Active;
    CubeInst := MB.ItemById("Calc_Cube").Open(NullAs ICalculatedCubeInstance;
    //Control selection of calculated cube
    //Dimension elements available before applying selection
    Debug.WriteLine("Calculated cube");
    Debug.Indent;
    For Each Inst In CubeInst.Destination.Dimensions Do
        Debug.WriteLine("Dimension: " + Inst.Name + "; Available elements: " + Inst.Elements.Count.ToString);
    End For;
    DimSS := CubeInst.Destination.CreateDimSelectionSet;
    //Selection of element in controlling dimension
    DimSS.FindById("Dim_1").SelectElement(0False);
    //Create an object for controlling selection of dimensions of calculated cube
    SelControl := CubeInst.CreateApply(Null, SelectionControlApplyMode.Apply);
    //Indicate source selection
    SelControl.SourceSelection := DimSS;
    //Use
    CubeInst.Apply(SelControl);
    //Output set of elements,
    //that are available in dimensions after applying selection
    For Each Inst In CubeInst.Destination.Dimensions Do
        Debug.WriteLine("Dimension: " + Inst.Name + "; Available elements: " + Inst.Elements.Count.ToString);
    End For;
    Debug.Unindent;

    //Control selection of source calculated cube
    //Source, to which management is applied
    Source := CubeInst.Sources.Item(0);
    //Elements of dimensions, available before use selection
    Debug.WriteLine("The first data source of the calculated cube");
    Debug.Indent;
    For Each Inst In Source.Source.Dimensions Do
        Debug.WriteLine("Dimension: " + Inst.Name + "; Available elements: " + Inst.Elements.Count.ToString);
    End For;
    DimSS := Source.Source.CreateDimSelectionSet;
    //Selection of element in controlling dimension
    DimSS.FindById("Dim_1").SelectElement(1False);
    //Create an object to control selection dimensions of calculated cube source
    SelControl := CubeInst.CreateApply(Source, SelectionControlApplyMode.Apply);
    //Indicate source selection
    SelControl.SourceSelection := DimSS;
    //Use
    CubeInst.Apply(SelControl);
    //Output set of elements,
    //that are available in dimensions after applying selection
    For Each Inst In Source.Source.Dimensions Do
        Debug.WriteLine(Dimension:  + Inst.Name + ; Available elements:  + Inst.Elements.Count.ToString);
    End For;
    Debug.Unindent;
End Sub UserProc;

After executing the example selection control parameters are applied to the calculated cube and for its first data source. Elements, available by dimensions before and after the use of selection control parameters, are displayed in the development environment.

See also:

ICalculatedCubeInstance