IndexInHeader: Integer;
IndexInHeader: integer;
The IndexInHeader property determines index of the element in the header, by which sorting is executed.
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.
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.
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.Pivot;
…
Public Shared Sub Main(Params: StartParams);
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 := Params.Metabase;
// 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.psdAsc;
// Sort by third table row
SortItem.Kind := PivotSortKind.pskRow;
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, uinteger.MaxValue);
Tran.Expression.AsString := "1/{Value[t]}";
End If;
Tran.Enabled := True;
// Save dimensions
(Express As IMetabaseObject).Save();
End Sub;
See also: