IPivot.AggregationElement

Fore Syntax

AggregationElement: Integer;

Fore.NET Syntax

AggregationElement: uinteger;

Description

The AggregationElement property determines the element, by which matrix aggregated data is available by fixed dimensions.

Comments

Data aggregation method on multiple selection in fixed dimensions is set in the IPivot.FixedElementsAggregation property. To save aggregated data in output matrix, set some negative element index in the AggregationElement property. To get aggregated data, set in matrix coordinate as an element for the last dimension the element index specified in AggregationElement.

To check if data is aggregated, use the IPivot.IsAggregationCalced property.

Fore Example

Executing the example requires that the repository contains an express report with the EXPRESS identifier. There is a dimension with the COUNTRY identifier among source dimensions. This dimension is included in the report into the list of fixed ones.

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

Sub UserProc;
Var
    MB: IMetabase;
    Analyzer: IEaxAnalyzer;
    Pivot: IPivot;
    DimSel: IDimSelection;
Begin
    MB := MetabaseClass.Active;
    Analyzer := MB.ItemById("EXPRESS").Bind As IEaxAnalyzer;
    //Table with express report data
    Pivot := Analyzer.Pivot;
    Pivot.FixedElementsAggregation := PivotAggregationOperation.None;
    //Display matrix in console window
    LogMatrix(Pivot.Matrix);
    Debug.WriteLine("=======================================================");
    Pivot.FixedElementsAggregation := PivotAggregationOperation.Sum;
    //Element, by which aggregated data is available
    Pivot.AggregationElement := -2;
    DimSel := Pivot.Selection.FindById("COUNTRY");
    DimSel.SelectElement(0False);
    DimSel.SelectElement(1False);
    DimSel.SelectElement(2False);
    //Display matrix in console window
    LogMatrix(Pivot.Matrix);
    //Check aggregation result
    Debug.WriteLine("=======================================================");
    If Pivot.IsAggregationCalced Then
        Debug.WriteLine("Aggregation is calculated")
    Else
        Debug.WriteLine("Aggregation is not calculated");
    End If;
End Sub UserProc;

//Display matrix in console window
Sub LogMatrix(Matrix: IMatrix);
Var
    Iterator: IMatrixIterator;
    Coord: IMatrixCoord;
    Item: String;
    i: Integer;
Begin
    Iterator := Matrix.CreateIterator;
    Coord := Matrix.CreateCoord;
    Iterator.Move(IteratorDirection.First);
    Debug.WriteLine("Elements:");
    While Iterator.Valid Do
        Iterator.PutCurrentPos(Coord);
        Item := "[";
        For i := 0 To Coord.Count - 1 Do
            If i > 0 Then
                Item := Item + ", ";
            End If;
            Item := Item + Coord.Item(i).ToString;
        End For;
        Item := Item + "] ";
        Item := Item + (Iterator.Value As Double).ToString;
        Debug.WriteLine(Item);
        Iterator.Move(IteratorDirection.Next);
    End While;
End Sub LogMatrix;

On executing the example the development environment console displays two matrices: the matrix with table source data and the matrix obtained after aggregation on multiple selection in the COUNTRY fixed dimension. Aggregated values are saved by the -2 element.

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.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Pivot;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Analyzer: IEaxAnalyzer;
    Pivot: IPivot;
    DimSel: IDimSelection;
Begin
    MB := Params.Metabase;
    Analyzer := MB.ItemById["EXPRESS"].Bind() As IEaxAnalyzer;
    //Table with express report data
    Pivot := Analyzer.Pivot;
    Pivot.FixedElementsAggregation := PivotAggregationOperation.paoNone;
    //Display matrix in console window
    LogMatrix(Pivot.Matrix);
    System.Diagnostics.Debug.WriteLine("=======================================================");
    Pivot.FixedElementsAggregation := PivotAggregationOperation.paoSum;
    //Element, by which aggregated data is available
    Pivot.AggregationElement := -2 As UInteger;
    DimSel := Pivot.Selection.FindById("COUNTRY");
    DimSel.SelectElement(0False);
    DimSel.SelectElement(1False);
    DimSel.SelectElement(2False);
    //Display matrix in console window
    LogMatrix(Pivot.Matrix);
    //Check aggregation result
    System.Diagnostics.Debug.WriteLine("=======================================================");
    If Pivot.IsAggregationCalced Then
        System.Diagnostics.Debug.WriteLine("Aggregation is calculated")
    Else
        System.Diagnostics.Debug.WriteLine("Aggregation is not calculated");
    End If;
End Sub;

//Display matrix in console window
Shared Sub LogMatrix(Matrix: IMatrix);
Var
    Iterator: IMatrixIterator;
    Coord: IMatrixCoord;
    Item: String;
    i: Integer;
Begin
    Iterator := Matrix.CreateIterator();
    Coord := Matrix.CreateCoord();
    Iterator.Move(IteratorDirection.itdFirst);
    System.Diagnostics.Debug.WriteLine("Elements:");
    While Iterator.Valid Do
        Iterator.PutCurrentPos(Coord);
        Item := "[";
        For i := 0 To Coord.Count - 1 Do
            If i > 0 Then
                Item := Item + ", ";
            End If;
            Item := Item + Coord.Item[i].ToString();
        End For;
        Item := Item + "] ";
        Item := Item + (Iterator.Value As Double).ToString();
        System.Diagnostics.Debug.WriteLine(Item);
        Iterator.Move(IteratorDirection.itdNext);
    End While;
End Sub LogMatrix;

See also:

IPivot