CalcMethod: CubeCalcMethod;
CalcMethod: Prognoz.Platform.Interop.Cubes.CubeCalcMethod;
The CalcMethod property determines value calculation mode of calculated fact on cube creation.
Executing the example requires that the repository contains a standard cube with the STD_CUBE identifier. Cube facts dimension has at least three elements: two first elements are linked to the data source fields, the third element has no binding. Add links to the Cubes, Db, Dimensions and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
StdCube: IStandardCube;
StdCubeDest: IStandardCubeDestination;
CalcBind: IStandardCubeCalculatedFactBinding;
Begin
MB := MetabaseClass.Active;
StdCube := MB.ItemById("STD_CUBE").Edit As IStandardCube;
StdCubeDest := StdCube.Destinations.Item(0);
//Binding of the calculated fact
CalcBind := StdCubeDest.CalcBindings.Binding(3) As IStandardCubeCalculatedFactBinding;
CalcBind.Formula.AsString := "(@[2]*100)/@[1]";
CalcBind.CalcMethod := CubeCalcMethod.BySelection;
(StdCube As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
StdCube: IStandardCube;
StdCubeDest: IStandardCubeDestination;
CalcBind: IStandardCubeCalculatedFactBinding;
Begin
MB := Params.Metabase;
StdCube := MB.ItemById["STD_CUBE"].Edit() As IStandardCube;
StdCubeDest := StdCube.Destinations.Item[0];
//Binding of the calculated fact
CalcBind := StdCubeDest.CalcBindings.Binding[3] As IStandardCubeCalculatedFactBinding;
CalcBind.Formula.AsString := "(@[2]*100)/@[1]";
CalcBind.CalcMethod := CubeCalcMethod.ccmBySelection;
(StdCube As IMetabaseObject).Save();
End Sub;
Example execution sets up cube calculated fact. Calculated fact formula calculates percent value of the second fact towards the first one. Calculation is made according to the cube selection.
See also: