PivotFilterCollection.Add(PivotField, PivotFilterType) Method
Applies a date filter to the specified PivotTable field.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
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 date filter to be applied to the field. |
Returns
Type | Description |
---|---|
PivotFilter | A PivotFilter object that represents the applied filter. |
Remarks
Use the Add method to filter date and time values in a row or column field to display dates that fall within a specified time period (next, this or last week, month, year, etc.).
The following example demonstrates how to apply a filter to the “Date” field to show sales data for the 2nd quarter.
Dim worksheet As Worksheet = workbook.Worksheets("Report6")
workbook.Worksheets.ActiveWorksheet = worksheet
' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Access the "Date" field.
Dim field As PivotField = pivotTable.Fields(0)
' Filter the "Date" field to display sales for the second quarter.
pivotTable.Filters.Add(field, PivotFilterType.SecondQuarter)
To filter the report data by dates that are before, after or equal to the specified date, or between two dates, use the Add method overloads with the additional parameters of the FilterValue type allowing you to specify one or two criteria values depending on the selected filter type.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(PivotField, PivotFilterType) 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.