FlexPivot allows you to sort and filter the pivot data to show the top N records. This is useful to filter out smaller sections of the data and add clarity to the analysis. The Top N Filter is the best option when you want to filter elements that have the highest values from a random list and the Bottom N Filter is great when it comes to filter elements with the lowest values. For example, you can use the Top N or Bottom N filtering is to display the top-selling or bottom-selling products for analyzing the sales performance.
In FlexPivot, you can apply Top N Filters programmatically using the C1FlexPivotFilter class, which provides the TopNValueField property to select a value field, the TopNRule enumeration to choose between the top N or bottom N elements, and the TopN or BottomN properties to assign the number of elements to be filtered.
C# |
Copy Code
|
---|---|
//Apply Top N Filter to show top 3 selling products in every country C1.FlexPivot.C1FlexPivotFilter topNfilter = fpEngine.Fields["Salesperson"].Filter; topNfilter.Clear(); topNfilter.TopNValueField = fpEngine.Fields["ExtendedPrice"]; topNfilter.TopNRule = C1.FlexPivot.TopNRule.TopN; topNfilter.TopN = 2; |
To display top N filtering at runtime: