IPivotSortItem.IndexInHeader

Syntax

IndexInHeader: Integer;

Description

The IndexInHeader property determines index of the element in the header, by which sorting is executed.

Comments

To use this property it is required that the IPivotSortItem.Kind property is set to PivotSortKind.Row or PivotSortKind.Column.

NOTE. Use the property by setting only one index and for one column or row.

Example

Executing the example requires that the repository contains an express report with the EXPRESS identifier containing a table.

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

Sub UserProc;
Var
    MB: IMetabase;
    Express: IEaxAnalyzer;
    Pivot: IPivot;
    SortItem: IPivotSortItem;
    Getter: IDataAreaTransformationsGetter;
    Slice: IEaxDataAreaSlice;
    Sel: IDimSelection;
    SelSet: IDimSelectionSet;
    i: Integer;
    Trans: IEaxDataAreaTransformations;
    Tran: IEaxDataAreaTransformation;
Begin
    // Get repository
    MB := MetabaseClass.Active;
    // Get express report
    Express := MB.ItemById("EXPRESS").Edit As IEaxAnalyzer;
    // Get table
    Pivot := Express.Pivot;
    // Remove all data sortings
    Pivot.Sorter.Clear;
    // Add a table sorting
    SortItem := Pivot.Sorter.Add;
    // Check if sorting is enabled
    If Not Pivot.Sorter.Enabled Then
        Pivot.Sorter.Enabled := True;
    End If;
    // Ascending sorting
    SortItem.Direction := PivotSortDirection.Asc;
    // Sort by third table row
    SortItem.Kind := PivotSortKind.Row;
    SortItem.IndexInHeader := 2;
    // Sort by formula
    SortItem.UseTransformationValues := True;
    Getter := SortItem As IDataAreaTransformationsGetter;
    Slice := Express.DataArea.Slices.Item(0);
    SelSet := SortItem.Selection.CreateCopy;
    For i := 0 To SelSet.Count - 1 Do
            Sel := SelSet.Item(i);
            Sel.DeselectAll;
        End For;
    // Add a formula
    Trans := Slice.GetTransformations(Getter);
        If Trans.Count > 0 Then
            Tran := Trans.Item(0);
        Else
            Tran := Trans.Add(SelSet, Null, -1);
            Tran.Expression.AsString := "1/{Value[t]}";
        End If;
        Tran.Enabled := True;
    // Save dimensions
    (Express As IMetabaseObject).Save;
End Sub UserProc;

After executing the example express report table is sorted by the third row according to the specified formula.

See also:

IPivotSortItem