Skip to main content
Row

PivotFilterCollection.Add(PivotField, PivotDataField, PivotFilterType, FilterValue, 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 firstValue,
    FilterValue secondValue
)

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 the value filter to be applied to the field.

firstValue FilterValue

A FilterValue object that specifies the first filter criteria value.

secondValue FilterValue

A FilterValue object that specifies the second 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. 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.

View Example

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)

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.

See Also