# Filtering

The PivotGridV2 supports filtering both in the OLAP and flat data-binding scenarios.

The PivotGridV2 uses [`kendo.data.PivotDataSource`](https://www.telerik.com/aspnet-mvc/documentation/api/pivotdatasource) to perform `label` filtration. However, it filters only by the caption value of the members.

The filter descriptor is similar to [the filter option of the `kendo.data.DataSource`](https://www.telerik.com/aspnet-mvc/documentation/api/datasource) and contains the following options:

* `field`—The full path to the tuple member. For example, `[Date].[Calendar].[Calendar Year].&[2005]`.
* `operator`—All operators that work with strings. Note that the widget treats field values as strings.
* `value`—The filter value.

### Filtering when using Xmla DataSource

To set a predefined filter when using Xmla data use the above-described approach and set the filter configuration of the PivotDataSource, following the [guidelines for MDX queries](https://learn.microsoft.com/en-us/analysis-services/multidimensional-models/mdx/mdx-query-fundamentals-analysis-services?view=asallproducts-allversions) and [Members, Tuples, and Sets](https://learn.microsoft.com/en-us/analysis-services/multidimensional-models/mdx/working-with-members-tuples-and-sets-mdx?view=asallproducts-allversions).

```Razor HtmlHelper
    .Filter(f =>
    {
        f.Add("[Geography].[City]").StartsWith("Ev");
        f.Add("[Date].[Calendar]").In("[Date].[Calendar].[Calendar Year].&[2010],[Date].[Calendar].[Calendar Year].&[2013]");
    })
```

### Filtering when using Flat Data

Build the filter descriptor similar to [the filter option of the `kendo.data.DataSource`](https://docs.telerik.com/kendo-ui/api/data/datasource/configuration/filter).

```Razor HtmlHelper
    .Filter(f =>
    {
        f.Add(p=>p.ProductName).Contains("An");
        f.Add(p => p.Discontinued).IsEqualTo(true);
    })
```

## See Also

* [Basic Usage of the PivotGridV2 HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/PivotGridV2/index)

* [Server-Side API](https://www.telerik.com/aspnet-mvc/documentation/api/PivotGridV2)
