Consider the example of creating a calculated cube using the Fore language. To create a cube, the following objects must be in the repository:
A cube with the CUBE_SOURCE identifier that will be used as a data source for the created calculated cube.
This cube should contain a calendar dimension with the CALENDAR identifier in its structure.
The following example creates a new object that is Calculated Cube in the repository root and sets up its parameters:
The data source is set.
All dimensions from the source are moved to the calculated cube structure. The calendar dimension is fixed.
To execute the examples, add links to the Cubes, Dimensions, and Metabase system assemblies.
Sub CreateCalculatedCube;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
CalcCube: ICalculatedCube;
CubeModel: ICubeModel;
CubeDest: ICubeModelDestination;
CalcSource: ICalculatedCubeSource;
SourceDim, CalcDim: ICalculatedCubeDimension;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_CALCCUBE;
CrInfo.Id := "New_Calc_Cube";
CrInfo.Name := "New calculated cube";
CrInfo.Parent := MB.Root;
MObj := MB.CreateObject(CrInfo).Edit;
CalcCube := MObj As ICalculatedCube;
//Add the source, which values are used to execute calculations by formulas
CubeModel := Mb.ItemById("CUBE_SOURCE").Bind As ICubeModel;
CubeDest := CubeModel.Destinations.DefaultDestination;
CalcSource := CalcCube.Sources.Add(CubeDest);
//Add source cube dimensions to calculated cube structure
For Each SourceDim In CalcSource.Dimensions Do
CalcDim := CalcCube.Dimensions.Add(SourceDim.Dimension);
If (SourceDim.Dimension As IMetabaseObject).Id = "CALENDAR" Then
SourceDim.Fixed := True;
CalcDim.Fixed := True;
End If;
End For;
MObj.Save;
End Sub CreateCalculatedCube;
See also: