Displaying Top N Values for a Field
- 2 minutes to read
At times, end-users do not wish to browse an entire report and only need to see the best or worst results. For this purpose, Pivot Grid provides the Top N Values feature that can be used to limit the number of field values displayed to the specified number of topmost values according to the sort order.
Requires installation of WinForms Subscription. Download.
To enable this feature, use the PivotGridFieldBase.TopValueCount property. This property allows you to restrict the number of field values that are displayed along the column or row axis.
By default, the PivotGridFieldBase.TopValueCount property determines the absolute number of field values to display. You can also use this property to specify the number of displayed field values as a percentage ratio. Note that in this instance you should set the PivotGridFieldBase.TopValueType property to PivotTopValueType.Percent.
The meaning of this percentage ratio depends on the current data binding mode as follows.
- In a regular data binding mode, the PivotGridFieldBase.TopValueCount property value defines the percentage of the displayed field values among all field values. For instance, if the PivotGridFieldBase.TopValueCount property is set to 50, Pivot Grid Control will display the first half of field values in the current field.
- In an OLAP mode, Pivot Grid Control will display top values, whose cumulative total is equal to or greater than a specified percentage. For instance, if the PivotGridFieldBase.TopValueCount property is set to 50, Pivot Grid Control will display values whose cumulative total is not less than a half of the Grand Total value.
If the Top N Values feature is enabled, Pivot Grid Control displays the first field values according to the current sort order. The other values are hidden and are not used to calculate totals. Nevertheless, you can display this information by setting the sorted field’s PivotGridFieldBase.TopValueShowOthers property to true. The remaining (hidden) values are combined into a single item (“Others”) as a result.