Item(Index: Integer): ICalculatedCubeFormula;
Index. Formula index.
The Item property returns the formula, which index is passed by the Index parameter.
There is at least one formula by each coordinate. If the cube has the dimension that controls selection of formula actual period, formulas for various periods are added by the Add method.
Executing the example requires that the repository contains a calculated cube with the Calc_Cube identifier. The source cube and the calculated cube contain two dimensions that are not fixed.
Sub UserProc;
Var
MB: IMetabase;
CubeInst: ICalculatedCubeInstance;
Coord, SourceCoord: ICalculatedCubeInstanceCoord;
Formulas: ICalculatedCubeFormulas;
Formula: ICalculatedCubeFormula;
Begin
MB := MetabaseClass.Active;
CubeInst := MB.ItemById("Calc_Cube").Open(Null) As ICalculatedCubeInstance;
//Get coordinate in calculated cube
Coord := CubeInst.CreateCoord;
Coord.MatrixCoord.Item(0) := 0;
Coord.MatrixCoord.Item(1) := 0;
//Get coordinate from source
SourceCoord := CubeInst.CreateSourceCoord(CubeInst.Sources.Item(0));
SourceCoord.MatrixCoord.Item(0) := 0;
SourceCoord.MatrixCoord.Item(1) := 0;
//Get formulas
Formulas := CubeInst.Formula(Coord);
Formula := Formulas.Item(0);
Formula.Expression.AsString := SourceCoord.AsTerm + "*3.14";
Formulas.Save;
CubeInst.SaveFormulas;
End Sub UserProc;
After executing the example a formula is set by the specified cube coordinate. A term that refers to appropriate coordinate in the source cube is used in the formula expression.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
CubeInst: ICalculatedCubeInstance;
Coord, SourceCoord: ICalculatedCubeInstanceCoord;
Formulas: ICalculatedCubeFormulas;
Formula: ICalculatedCubeFormula;
Begin
MB := Params.Metabase;
CubeInst := MB.ItemById["Calc_Cube"].Open(Null) As ICalculatedCubeInstance;
//Get coordinate in calculated cube
Coord := CubeInst.CreateCoord();
Coord.MatrixCoord.Item[0] := 0;
Coord.MatrixCoord.Item[1] := 0;
//Get coordinate from source
SourceCoord := CubeInst.CreateSourceCoord(CubeInst.Sources.Item[0]);
SourceCoord.MatrixCoord.Item[0] := 0;
SourceCoord.MatrixCoord.Item[0] := 0;
//Get formulas
Formulas := CubeInst.Formula[Coord];
Formula := Formulas.Item[0];
Formula.Expression.AsString := SourceCoord.AsTerm + "*3.14";
Formulas.Save();
CubeInst.SaveFormulas();
End Sub;
See also: