IMDCalculationSliceSumm.KeyFields

Syntax

KeyFields: String;

Description

The KeyFields property determines a list of fields containing key elements values used for linking with child elements.

Comments

Child elements are searched by values of these elements in the LookupFields fields. Fields in the list are separated with semicolon (;).

Example

Executing the example requires that the repository contains a database with the MDBD identifier, and two standard cubes CUBE_INPUT and CUBE_OUTPUT. These cubes are based on tables stored in this database. Each cube contains two dimensions: 1) Calendar dimension - fixed; 2) Dimension, based on table dictionary - by the elements of this dimension summation is set up.

Sub Main;

Var

MB: IMetabase;

CrInfo: IMetabaseObjectCreateInfo;

MObj: IMetabaseObject;

MDCalc: IMDCalculation;

Cube: ICubeModel;

Source: IMDCalculationSource;

Slices: IMDCalculationSlices;

Slice: IMDCalculationSlice;

FreeSlice: IMDCalculationSliceFree;

FixedSlice: IMDCalculationSliceFixed;

Sum: IMDCalculationSliceSumm;

Destination: IMDCalculationDestination;

FormulasTable: IMDCalculationFormulasTable;

TableForFormulas: ITable;

Begin

MB := MetabaseClass.Active;

CrInfo := MB.CreateCreateInfo;

CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MDCALCULATION;

CrInfo.Id := "MDCALC_1";

CrInfo.Name := Multidimensional calculation on server;

CrInfo.Parent := Null;

MObj := MB.CreateObject(CrInfo).Edit;

MDCalc := MObj As IMDCalculation;

//Add DB

MDCalc.Database := MB.ItemById("MDBD").Bind As IDatabase;

//Indicate source cube

Cube := MB.ItemById("CUBE_INPUT").Bind As ICubeModel;

Source := MDCalc.Sources.AddCube(Cube);

Slices := Source.Slices;

//Calendar dimension is fixed

Slice := Slices.Item(0);

Slice.FixType := MDCalculationSliceFixType.Fixed;

FixedSlice := Slice.Fixed;

//Second dimension, by the elements of which summation is performed

Slice := Slices.Item(1);

FreeSlice := Slice.Free;

Sum := FreeSlice.Summ;

Sum.Data := (FreeSlice.Dimension As IStandardDimension).Blocks.Item(0).Dataset;

Sum.KeyFields := "ID";

Sum.LookupFields := "PARENTID";

Sum.Enabled := True;

//Indicate destination cube

Destination := MDCalc.Destination;

Destination.SetCube(MB.ItemById("CUBE_OUTPUT").Bind As ICubeModel);

Slices := Destination.Slices;

//Calendar dimension is fixed

Slice := Slices.Item(0);

Slice.FixType := MDCalculationSliceFixType.Fixed;

FixedSlice.Mapping := Slice;

//Create new formula table

FormulasTable := MDCalc.FormulasTable;

TableForFormulas := FormulasTable.Create;

FormulasTable.Attach(TableForFormulas);

MObj.Save;

End Sub Main;

After executing the example the Multidimensional Calculation on DB Server is created in the repository root. One source cube and one destination cube are set, a new formulas table is created. Calendar dimensions of cubes are fixed and mapped with each other. It is possible to set up summation by child elements in formulas for the elements of the second source dimension. Parent elements are selected by values of the Id field of the data source linked to the second dimension of the data source. Appropriate child elements are searched by values of parent elements contained in the PARENTID field.

See also:

IMDCalculationSliceSumm