IPivotEvaluatorDimCalculatesItem.AddCalculatedElement

Syntax

AddCalculatedElement(Name: String; RelationElement: Integer; Relation: DimRelation): Integer;

Parameters

Name. Name of a new calculated element.

RelationElement. Element, relative to which a calculated element will be placed.

Relation. Insert position of calculated element relative to the RelationElement element.

Description

The AddCalculatedElement method creates a new calculated element for this dimension.

Example

Executing the example requires a form with the button named Button1, the TabSheetBox component and the UiErAnalyzer component named UiErAnalyzer1, which is a data source for TabSheetBox.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    OLAP: IEaxAnalyzer;
    Pivot: IPivot;
    Dim: IDimInstance;
    Calcs: IPivotEvaluatorDimCalculates;
    Calc: IPivotEvaluatorDimCalculatesItem;
    Sel: IDimSelection;
    Elements: IDimElements;
    Element1, Element2: String;
    i: Integer;
Begin
    OLAP := UiErAnalyzer1.ErAnalyzer;
    Pivot := OLAP.Pivot;
    Dim := Pivot.TopHeader.Dim(
0);
    Calcs := Pivot.Evaluator.DimCalculates;
    Calc := Calcs.FindByDimKey(Dim.Key);
    Sel := Pivot.Selection.FindByKey(Dim.Key);
    Elements := Calc.Dim.Elements;
    Element1 := Elements.Id(Sel.Element(
0));
    Element2 := Elements.Id(Sel.Element(
1));
    i := Calc.AddCalculatedElement(Element1 + 
"+" + Element2, Sel.Element(1), DimRelation.Next);
    Calc.Expression(i).AsString := 
"@" + Element1 + "+ @" + Element2;   
End Sub Button1OnClick;

Clicking the button creates a new calculated element that sums up the first and the second dimension elements for the first element. Calculation is executed for the elements that are in a dimension selection.

Source data:

A table with calculated element:

See also:

IPivotEvaluatorDimCalculatesItem