Creating a Cube View

Consider the example of creating a view cube with the use of the Fore language. Creating a cube view requires that the repository contains another cube with the Cube_1 identifier. This cube must have a dimension with the CALENDAR identifier in its structure.

The following example creates a new object that is Cube View in the repository root and sets up its parameters:

To execute the examples, add links to the Cubes, Dimensions, Matrix, and Metabase system assemblies.

Example

Sub CreateViewCube;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    ViewCube: ICubeView;
    SourceCube: ICubeModel;
    FixInfo: ICubeDimensionFixInfo;
    DimFix: ICubeDimensionFix;
Begin
    MB := MetabaseClass.Active;
    //Information for creating a new repository object
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_CUBEVIEW;
    CrInfo.Id := "New_View_Cube";
    CrInfo.Name := "New cube view";
    CrInfo.Parent := MB.Root;
    //Set up cube parameters
    MObj := MB.CreateObject(CrInfo).Edit;
    ViewCube := MObj As ICubeView;
    //Specify source cube
    SourceCube := MB.ItemById("CUBE_1").Bind As ICubeModel;
    ViewCube.Cube := SourceCube.Destinations.DefaultDestination;
    //Fix dimension
    FixInfo := ViewCube.FixInfo;
    DimFix := FixInfo.ItemByDim(ViewCube.Cube.Dimensions.FindById("CALENDAR"));
    DimFix.Fixed := True;
    //Specify method for aggregation of values by fixed elements
    DimFix.Operation := BasicAggregatorOperation.Sum;
    //Select the whole level, on which the first element is located
    DimFix.Selection.SelectSiblings(0);
    //Save cube
    MObj.Save;
End Sub CreateViewCube;

See also:

Examples