Skip to main content
Tag

PivotGridField.TopValueCount Property

Gets or sets an absolute or relative number of field values to be displayed for the current column or row field. This is a dependency property.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v23.2.dll

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public int TopValueCount { get; set; }

Property Value

Type Description
Int32

An integer value that specifies the number of field values to be displayed for the current column or row field.

Remarks

The PivotGridControl allows you to display top field values according to the current sort order, while ignoring the values that follow these first values.

If the TopValueCount property is set to 0, PivotGridControl displays all the values of the current row field (or column field) along the control’s left (or top) edge.

If the PivotGridField.TopValueType property is set to FieldTopValueType.Absolute, the TopValueCount property determines the absolute number of top field values to display. For instance, if there are 20 unique field values and the TopValueCount property is set to 10, only the 10 top field values will be displayed.

If the PivotGridField.TopValueType property is set to FieldTopValueType.Percent, the effect depends on the current data binding mode as follows:

  • In a regular data binding mode, the TopValueCount property determines the number of field values to display relative to the total number of field values. For instance, if there are 20 unique field values and the TopValueCount property is set to 10, only 2 top field values (10% out of 20) will be displayed.
  • In an OLAP mode, PivotGridControl will display top values whose cumulative total is equal to or greater than a specified percentage. For instance, if the TopValueCount property is set to 10, PivotGridControl will display values whose cumulative total is not less than 10% of the Grand Total value.

The TopValueCount property, along with the Sorting by Summary feature, allows you to implement a Top N Values report, which will show only the first records while ignoring the rest. The Top Values demo illustrates this functionality.

Note

In OLAP mode, totals are calculated against all values, even if the Top N values feature is enabled.

Example

This example demonstrates how to avoid browsing an entire report, but only show the best or worst results. For this purpose, the PivotGridControl provides the Top N Values feature, which can be used to limit the number of displayed field values to the specified number of topmost values according to the sort order.

To enable this feature, the PivotGridField.TopValueCount property must be used. This property allows you to restrict the number of field values that are displayed along the column or row axis.

<Window x:Class="HowToBindToMDB.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid"
        Title="MainWindow" Height="350" Width="525"  Loaded="Window_Loaded">
    <Grid Margin="7">
        <dxpg:PivotGridControl HorizontalAlignment="Left" Name="pivotGridControl1"
                               VerticalAlignment="Top">
            <dxpg:PivotGridControl.Fields>
                <dxpg:PivotGridField x:Name="fieldCountry" FieldName="Country" Area="RowArea"/>
                <dxpg:PivotGridField x:Name="fieldCustomer" FieldName="Sales Person" Area="RowArea"
                                     SortByField="{Binding ElementName=fieldExtendedPrice}"
                                     Caption="Customer" TopValueCount="3"
                                     TopValueShowOthers="True"
                                     SortOrder="Descending"/>
                <dxpg:PivotGridField x:Name="fieldExtendedPrice" FieldName="Extended Price"
                                     Area="DataArea" CellFormat="c0" />
            </dxpg:PivotGridControl.Fields>
        </dxpg:PivotGridControl>
    </Grid>
</Window>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TopValueCount property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also