Add(DateBegin: DateTime; DateEnd: DateTime): ICalculatedCubeFormula;
DateBegin. Formula actual start date.
DateEnd. Formula actual end date.
The Add method adds a new formula.
The method is used if calculated cube has a dimension that controls selection of formula actual period. If formula actual period control is set up in the cube, use the ICalculatedCubeFormulas.Item property to get formulas.
Executing the example requires that the repository contains a calculated cube with the Calc_Cube identifier. A source cube and a calculated cube contain two dimensions that are not fixed, also the dimension, controlling the selection of formula actual period, is set.
Sub UserProc;
Var
MB: IMetabase;
CubeInst: ICalculatedCubeInstance;
Coord, SourceCoord: ICalculatedCubeInstanceCoord;
Formulas: ICalculatedCubeFormulas;
Formula: ICalculatedCubeFormula;
d: DateTime;
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;
Formulas := CubeInst.Formula(Coord);
Formula := Formulas.Item(Formulas.Count - 1);
d := Formula.DateEnd;
Formula := Formulas.Add(d.AddDays(d, 1), d.AddMonths(d, 6));
Formula.Expression.AsString := SourceCoord.AsTerm + "*10";
Formulas.Save;
CubeInst.SaveFormulas;
End Sub UserProc;
After executing the example one formula is added to the calculated cube by the specified coordinate. A term that refers to appropriate coordinate in the source cube is used in the formula expression.
See also: