Skip to main content
Row

PivotFilterCollection.Add(PivotField, PivotFilterType, FilterValue, FilterValue) Method

Applies a label or date 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,
    PivotFilterType filterType,
    FilterValue firstValue,
    FilterValue secondValue
)

Parameters

Name Type Description
field PivotField

A PivotField object that specifies a row or column field that should be filtered.

filterType PivotFilterType

A PivotFilterType enumeration member specifying the type of the 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

Use the Add method to filter item labels in a specific row or column field by two criteria values. In particular, this method allows you to display items for which the label is between (PivotFilterType.CaptionBetween) or not between (PivotFilterType.CaptionNotBetween) the specified values.

The following example demonstrates how to apply a filter to the “Product” field to display a list of products whose names start with the letters M-Z.

// Access the pivot field by its name in the collection.
PivotField field = pivotTable.Fields["Product"];
// Filter the "Product" field to display products whose names start with the letters M-Z.
pivotTable.Filters.Add(field, PivotFilterType.CaptionBetween, "M", "Z");

The image below shows the result of the code’s execution.

PivotField_Filtering_CaptionBetween

Tip

To perform more versatile filtering, you can use the wildcard characters. The asterisk * matches any number of characters, while the question mark ? represents a single character. To filter labels containing a specific character, such as the asterisk, question mark or tilde, put the tilde (~) before it.

If the a row or column field you wish to filter contains date items, you also use the current Add method to construct a filter criteria showing dates that are between (PivotFilterType.DateBetween) or not between (PivotFilterType.DateNotBetween) the specified start and end dates.

See Also