If your user needs to focus on one section of their data, you'll need to include filters in your PivotGrid. OLAP supports two approaches to filtering:
- You can apply a filter directly to the source data. For example, you could retrieve sales data for the last 12 months only, and perform all your analyses based on that subset of the data. The advantage of this approach is you would never download data that won’t be used in the analysis. The drawback is that users would not be able to see any data outside the subset you chose.
- You can use filter fields to filter that data using OLAP. The advantage of this approach is you get complete flexibility over what data should be included in each view. For example, you could create separate views to see sales in different groups of countries.
To filter data using OLAP, drag the field you want to filter on into the view. For example, in our sales by product example, we'll filter out the US sales to see how they affect the overall picture. Start by dragging the “Country” field into the “Filters” list of the PivotPanel (you can apply filters to fields in any other lists as well):
Next, right-click the “Country” field, select “Field Settings…” and click the “Filter Edit…” button to set the filter:
You can apply filters by condition or by value. In this case, we will simply uncheck the “US” item from the list and click OK.
The filter icon next to the “Country” field indicates there’s an active filter.
After excluding US sales from the analysis, the grand total dropped from about 250 million to 220 million.
More from the ASP.NET MVC OLAP
Demos: ASP.NET 4.0 | ASP.NET Core
Take a look at the documentation for more details.
Here's the full OLAP series:
- Getting Started with ASP.NET MVC OLAP: Create Basic Pivot Tables
- Answer Recurring Questions with Pre-Defined Views
- Filtering Data in a PivotGrid