wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridfield-69754e7e.md
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.v25.2.dll
NuGet Package : DevExpress.Wpf.PivotGrid
public int TopValueCount { get; set; }
Public Property TopValueCount As Integer
| Type | Description |
|---|---|
| Int32 |
An integer value that specifies the number of field values to be displayed for the current column or row field.
|
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:
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.
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.
f.SortByConditions.AddRange(sortConditions.Select(c => new SortByCondition(c.Key, c.Value)));
f.TopValueCount = 5;
f.TopValueShowOthers = true;
f.SortByConditions.AddRange(sortConditions.Select(Function(c) New SortByCondition(c.Key, c.Value)))
f.TopValueCount = 5
f.TopValueShowOthers = True
See Also