IMDCalculationFormulaUnaryOperation.UnaryOperation

Syntax

UnaryOperation: MDCalculationFormulaUnaryOperation;

Description

The UnaryOperation property determines a type of unary operation used as a formula operand.

Example

Executing the example requires that the repository contains multidimensional calculation on DB server with the MDCalc_1 identifier.

Sub Main;

Var

MB: IMetabase;

MDInst: IMDCalculationInstance;

Formulas: IMDCalculationFormulas;

Formula: IMDCalculationFormula;

FormulaExpression: IMDCalculationFormulaExpression;

Source: IMDCalculationSourceInstance;

Dest: IMDCalculationDestinationInstance;

Slices: IMDCalculationSlicesInstance;

Operand: IMDCalculationFormulaOperand;

DestCoo, SourceCoo: IMatrixCoord;

ElementKey, SourceElKey: IMDCalculationFormulaElementKey;

UnaryOperand: IMDCalculationFormulaUnaryOperation;

CoordOperand: IMDCalculationFormulaElement;

i: Integer;

Begin

MB := MetabaseClass.Active;

MDInst := MB.ItemById("MDCalc_1").Open(Null) As IMDCalculationInstance;

Formulas := MDInst.CreateFormulas;

Formula := Formulas.Add;

FormulaExpression := Formula.Expression;

Source := MDInst.Sources.Item(0);

Slices := Source.Slices;

//Assign symbol - as an operand

Operand := FormulaExpression.CreateItem(MDCalculationFormulaOperandKind.UnaryOperation);

UnaryOperand := Operand As IMDCalculationFormulaUnaryOperation;

UnaryOperand.UnaryOperation := MDCalculationFormulaUnaryOperation.Minus;

FormulaExpression.InsertItem(Operand);

//Assign as an operand - coordinate in the source

Operand := FormulaExpression.CreateItem(MDCalculationFormulaOperandKind.Element);

SourceCoo := Source.NewCoord;

For i := 0 To Slices.Count - 1 Do

SourceCoo.Item(i) := 0;

End For;

SourceElKey := Source.CoordToKey(SourceCoo);

SourceElKey.FactIndex := 0;

CoordOperand := Operand As IMDCalculationFormulaElement;

CoordOperand.Key := SourceElKey;

FormulaExpression.InsertItem(Operand);

//Coordinate, by which formulas are written into the consumer

Dest := MDInst.Destination;

DestCoo := Dest.NewCoord;

Slices := Dest.Slices;

For i := 0 To Slices.Count - 1 Do

DestCoo.Item(i) := 0;

End For;

ElementKey := Dest.CoordToKey(DestCoo);

ElementKey.FactIndex := 0;

MDInst.WriteFormulas(ElementKey, Formulas);

End Sub Main;

After executing the example the formula is set for the specified data consumer element. The value by coordinate in the data consumer is calculated by the formula: 0 - the value by coordinate in the data source.

See also:

IMDCalculationFormulaUnaryOperation