Expression: IExpression;
The Expression property returns an object containing a formula expression.
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 Main;
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;
//Collecting coordinate in the calculated cube
Coord := CubeInst.CreateCoord;
Coord.MatrixCoord.Item(0) := 0;
Coord.MatrixCoord.Item(1) := 0;
//Collecting coordinate from the source
SourceCoord := CubeInst.CreateSourceCoord(CubeInst.Sources.Item(0));
SourceCoord.MatrixCoord.Item(0) := 0;
SourceCoord.MatrixCoord.Item(1) := 0;
Formulas := CubeInst.Formula(Coord);
//Collecting formula by the specified coordinate
Formula := Formulas.Item(0);
Formula.Expression.AsString := SourceCoord.AsTerm + "* 180 / 3.14";
Formulas.Save;
CubeInst.SaveFormulas;
End Sub Main;
After executing the example the formula for the obtained cube coordinate is changed. A term, referring to an appropriate coordinate in the source cube, is used in the expression.
See also: