officefileapi-devexpress-dot-spreadsheet-51f9d7a4.md
Represents a filter applied to a PivotTable field.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface PivotFilter
Public Interface PivotFilter
The following members return PivotFilter objects:
The PivotFilter objects are stored in the PivotFilterCollection collection, which can be accessed using the PivotTable.Filters property.
To create a new filter and apply it to a specific row or column field in the pivot table, use the PivotFilterCollection.Add method overloads. Different types of filters are available: you can construct the filter expression to display items that meet the specified criteria ( Label Filters and Date Filters ), or filter report data based on calculated values ( Value Filters ).
The following example applies a label filter to the “Region” field to display sales data only for the Southern region:
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 "Region" field.
Dim field As PivotField = pivotTable.Fields(0)
' Filter the "Region" field by text to display sales data for the "South" region.
pivotTable.Filters.Add(field, PivotFilterType.CaptionEqual, "South")
Worksheet worksheet = workbook.Worksheets["Report4"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Access the "Region" field.
PivotField field = pivotTable.Fields[0];
// Filter the "Region" field by text to display sales data for the "South" region.
pivotTable.Filters.Add(field, PivotFilterType.CaptionEqual, "South");
To remove a specific filter, you can either use the filter’s PivotFilter.Delete method or the Remove / RemoveAt methods of the PivotFilterCollection collection.
See Also