TermSum(Term: String; Index: Integer): MDCalculationFormulaElementSum;
Term. Character view of term mapped with the data source element, by which summation must be set up.
Index. Index of the dimension, by which summation is executed.
The TermSum property determines a summation method of child elements values for the element mapped with the Term term.
Executing the example requires that the repository contains multidimensional calculation on database server with the MDCalc_1 identifier.
Sub UserProc;
Var
MB: IMetabase;
MDInst: IMDCalculationInstance;
Source: IMDCalculationSourceInstance;
Parser: IMDCalculationExpressionParser;
SourceCoord, DestCoord: IMatrixCoord;
SourceKey, DestKey: IMDCalculationFormulaElementKey;
Dest: IMDCalculationDestinationInstance;
Formulas: IMDCalculationFormulas;
Formula: IMDCalculationFormula;
i: Integer;
Begin
MB := MetabaseClass.Active;
MDInst := MB.ItemById("MDCalc_1").Open(Null) As IMDCalculationInstance;
Source := MDInst.Sources.Item(0);
Parser := MDInst.CreateParser;
SourceCoord := Source.NewCoord;
For i := 0 To SourceCoord.Count - 1 Do
SourceCoord.Item(i) := 0;
End For;
SourceKey := Source.CoordToKey(SourceCoord);
Parser.TermKey("Term") := SourceKey;
Parser.TermSum("Term", 0) := MDCalculationFormulaElementSum.SumOwner;
Parser.Text := "Term";
Parser.Parse;
Dest := MDInst.Destination;
DestCoord := Dest.NewCoord;
For i := 0 To SourceCoord.Count - 1 Do
DestCoord.Item(i) := 0;
End For;
DestKey := Dest.CoordToKey(DestCoord);
Formulas := MDInst.CreateFormulas;
Formula := Formulas.Add;
Parser.Expression.CopyTo(Formula.Expression);
MDInst.WriteFormulas(DestKey, Formulas);
End Sub UserProc;
After executing the example a new formula is created for the specified data consumer element. The formula is obtained through text line string parse. The specified data source element is substituted into the expression instead of a term. Child elements values are summed together with parent element value by this element.
See also: