Creating Multidimensional Calculation on Database Server

Consider the example of creating a multidimensional calculation on database server with the use of the Fore language. To start creation, the repository should contain the following objects:

  1. A database with the DB identifier.

  2. Two standard cubes with the STD_SOURCE and STD_DESTINATION identifiers.

  3. Cubes should contain a calendar dimension with the CALENDAR identifier in its structure.

The following example creates a new object that is Multidimensional Calculation on DB Server in the repository root and sets up its parameters:

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

Example

Sub CreateMDCalculation;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    MDCalc: IMDCalculation;
    Cube: ICubeModel;
    Source: IMDCalculationSource;
    Destination: IMDCalculationDestination;
    FormulasTable: IMDCalculationFormulasTable;
    TableForFormulas: ITable;
    SourceSlice, DestinationSlice: IMDCalculationSlice;
Begin
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MDCALCULATION;
    CrInfo.Id := "New_MDCalculation";
    CrInfo.Name := "Multidimensional calculation on server";
    CrInfo.Parent := MB.Root;
    MObj := MB.CreateObject(CrInfo).Edit;
    MDCalc := MObj As IMDCalculation;
    //Specify database
    MDCalc.Database := MB.ItemById("DB").Bind As IDatabase;
    //Specify source cube
    Cube := MB.ItemById("STD_SOURCE").Bind As ICubeModel;
    Source := MDCalc.Sources.AddCube(Cube);
    SourceSlice := Source.Slices.FindById("CALENDAR");
    SourceSlice.FixType := MDCalculationSliceFixType.Fixed;
    //Specify destination cube
    Destination := MDCalc.Destination;
    Destination.SetCube(MB.ItemById("STD_DESTINATION").Bind As ICubeModel);
    //Fix calendar dimensions
    DestinationSlice := Destination.Slices.FindById("CALENDAR");
    DestinationSlice.FixType := MDCalculationSliceFixType.Fixed;
    SourceSlice.Fixed.Mapping := DestinationSlice;
    //Create a new formulas table
    FormulasTable := MDCalc.FormulasTable;
    TableForFormulas := FormulasTable.Create;
    FormulasTable.Attach(TableForFormulas);
    MObj.Save;
End Sub CreateMDCalculation;

See also:

Examples