IEaxDataAreaTransformations.AddFunction

Fore Syntax

AddFunction(FunctionName: String;
           Value: IDimSelection;
           CombineElement: Boolean;
           Args: Variant);

Fore.NET Syntax

AddFunction(FunctionName: string;
           Value: Prognoz.Platform.Interop.Dimensions.IDimSelection;
           CombineElement: boolean;
           Args: object);

Parameters

FunctionName. Name of the function to calculate totals (Total, SubTotal).

Value. Selection of elements by which totals should be obtained.

CombineElement. Splice attribute with source elements.

Args. Total data calculation method.

Description

The AddFunction method adds a transformation formula that calculates total/subtotal.

Comments

Description of various totals and calculation parameters is given in the Totals Calculation subsection.

Mandatory condition for transformation formula working is enabling of required totals calculation for rows/columns of table. If totals are not calculated, transformation formula returns empty values.

If the CombineElement parameter is set to True, the created element will be combined with the element, by which totals are calculated: the created element is a parent one relative to the source element. If the value is False, the element is created below the source element and is located at the same level with it.

As a value of the Args parameter it is required to specify name of one of the total types calculated for table. The names match the names of elements of the PivotEvaluatorElementType enumeration.

 Fore Example

Executing the example requires that repository contains express report with the EXPRESS identifier. Report data source in its structure has a dimension with the Regions identifier, this dimension is located by rows in the report.

Add links to the Dimensions, Express, Metabase, Pivot system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Express: IEaxAnalyzer;
    DArea: IEaxDataArea;
    Slice: IEaxDataAreaSlice;
    DimSel: IDimSelection;
    CalcTrs: IEaxDataAreaTransformations;
    Totals: IPivotEvaluatorTotals;
    Element: Integer;
Begin
    //Get repository
    MB := MetabaseClass.Active;
    //Get express report
    Express := MB.ItemById("Express").Edit As IEaxAnalyzer;
    //Data source slice
    DArea := Express.DataArea;
    Slice := DArea.Slices.Item(0);
    //Column totals
    Totals := Express.Pivot.Evaluator.Totals;
    Totals.ColumnTypes := PivotEvaluatorElementType.Sum;
    Totals.LevelTotals := True;
    Totals.HierarchyTotals := True;
    //Data transformation formulas in analytical area
    CalcTrs := Slice.CalcTransformations;
    //Add function for calculating totals
    DimSel := Express.Pivot.Selection.FindById("Regions").CreateCopy;
    Element := DimSel.FirstDimElement;
    DimSel.DeselectAll;
    DimSel.SelectElement(Element, False);
    CalcTrs.AddFunction("Total", DimSel, False"Sum");
    // Save changes
    (Express As IMetabaseObject).Save;
End Sub UserProc;

After executing the example a calculated element that calculates totals is added for the first selected element of the Regions dimension. In order this element works, calculation of totals (sum) is also enabled in the table by columns.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Pivot;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Express: IEaxAnalyzer;
    DArea: IEaxDataArea;
    Slice: IEaxDataAreaSlice;
    DimSel: IDimSelection;
    CalcTrs: IEaxDataAreaTransformations;
    Totals: IPivotEvaluatorTotals;
    Element: UInteger;
Begin
    //Get repository
    MB := Params.Metabase;
    //Get express report
    Express := MB.ItemById["Express"].Edit() As IEaxAnalyzer;
    //Data source slice
    DArea := Express.DataArea;
    Slice := DArea.Slices.Item[0];
    //Column totals
    Totals := Express.Pivot.Evaluator.Totals;
    Totals.ColumnTypes := (PivotEvaluatorElementType.peetSum As Integer);
    Totals.LevelTotals := True;
    Totals.HierarchyTotals := True;
    //Data transformation formulas in analytical area
    CalcTrs := Slice.CalcTransformations;
    //Add function for calculating totals
    DimSel := Express.Pivot.Selection.FindById("Regions").CreateCopy();
    Element := DimSel.FirstDimElement;
    DimSel.DeselectAll();
    DimSel.SelectElement(Element, False);
    CalcTrs.AddFunction("SubTotal", DimSel, False"Sum");
    // Save changes
    (Express As IMetabaseObject).Save();
End Sub;

See also:

IEaxDataAreaTransformations