PivotFilterCollection.Add(PivotField, PivotDataField, PivotFilterType, FilterValue) Method
Applies a value filter to the specified PivotTable field.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
PivotFilter Add(
PivotField field,
PivotDataField measureField,
PivotFilterType filterType,
FilterValue value
)
Parameters
Name | Type | Description |
---|---|---|
field | PivotField | A PivotField object that specifies a row or column field to which a filter should be applied. |
measureField | PivotDataField | A PivotDataField object that specifies a data field containing summary values to filter by. |
filterType | PivotFilterType | A PivotFilterType enumeration member specifying the type of value filter to be applied to the field. |
value | FilterValue | A FilterValue object that specifies the filter criteria value. |
Returns
Type | Description |
---|---|
PivotFilter | A PivotFilter object that represents the applied filter. |
Remarks
The current Add method overload allows you to filter items in a row or column field based on summary values in a data field. For example, you can display item values that are greater than (PivotFilterType.ValueGreaterThan, PivotFilterType.ValueGreaterThanOrEqual), less than (PivotFilterType.ValueLessThan, PivotFilterType.ValueLessThanOrEqual), equal (PivotFilterType.ValueEqual) or not equal to (PivotFilterType.ValueNotEqual) the specified filter criteria value.
This method also enables you to apply a “Top 10” filter. Use this type of filter to display the specified number of top or bottom items (PivotFilterType.Count), show the top or bottom values that contribute to the specified percent of the filtered field’s grand total (PivotFilterType.Percent), or filter for the top or bottom values that make up a specific sum (PivotFilterType.Sum). To specify what items (top or bottom) should be included in the filtering results, use the PivotFilter.Top10Type property.
The following example demonstrates how to apply the “Top 10” filter to the “Product” field to display two products with the lowest total sales.
Dim worksheet As Worksheet = workbook.Worksheets("Report4")
workbook.Worksheets.ActiveWorksheet = worksheet
' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Access the "Product" field.
Dim field As PivotField = pivotTable.Fields(1)
' Filter the "Product" field to display two products with the lowest sales.
Dim filter As PivotFilter = pivotTable.Filters.Add(field, pivotTable.DataFields(0), PivotFilterType.Count, 2)
filter.Top10Type = PivotFilterTop10Type.Bottom
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(PivotField, PivotDataField, PivotFilterType, FilterValue) method.
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.