PivotFilterCollection.Add(PivotField, PivotDataField, PivotFilterType, FilterValue, FilterValue) Method
Applies a value filter to the specified PivotTable field.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
#Declaration
PivotFilter Add(
PivotField field,
PivotDataField measureField,
PivotFilterType filterType,
FilterValue firstValue,
FilterValue secondValue
)
#Parameters
Name | Type | Description |
---|---|---|
field | Pivot |
A Pivot |
measure |
Pivot |
A Pivot |
filter |
Pivot |
A Pivot |
first |
Filter |
A Filter |
second |
Filter |
A Filter |
#Returns
Type | Description |
---|---|
Pivot |
A Pivot |
#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. In particular, you can display item values that are between (PivotFilterType.ValueBetween) or not between (PivotFilterType.ValueNotBetween) two specified values.
The following example demonstrates how to apply a value filter to the “Product” field to display products whose total sales fall between $6000 and $13000.
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 products with grand total sales between $6000 and $13000.
pivotTable.Filters.Add(field, pivotTable.DataFields(0), PivotFilterType.ValueBetween, 6000, 13000)
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(PivotField, PivotDataField, PivotFilterType, FilterValue, 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.