This is a migrated thread and some comments may be shown as answers.

Top N Filter TieBreak

3 Answers 468 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 29 Nov 2016, 06:11 PM

Hi Forum,

I am attempting to add a filter to a grid using the Top N filter operator with Value = 5 so that the grid contains only the top 5 rows based on the value in the column being used for the filter.  If, for example, 8 rows have the same value for this column, which is the highest value in the dataset, all 8 rows will be displayed in the grid.  

Is there a way to ensure an arbitrary tiebreak so that there are never more rows than the specified N value?

Thank you

 

3 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 30 Nov 2016, 04:05 PM
Hi Derek,

When filtering rule is applied first the records are ordered by the Expression in descending order and then the rank is assigned. If two or more records tie for a rank, each tied records receives the same rank and the filter may return more than the exact count specified in Value.

To avoid this, you can add a new data field wich can be a unique index for each record and use this data field as a filter expression. This way using TOP N operator will return the exact amount of records as specified in filter Value.


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Derek
Top achievements
Rank 1
answered on 01 Dec 2016, 07:01 PM

Hi Katia,

Thanks for getting back to me.  Is there a way I can use a top N filter that does not use a field that is part of the datasource (the datasource is a web API that I cannot edit)?  I tried setting up a filter on the table with:

Expression = RowNumber()

Operator = Rop N

Value = 5

However this returns an error saying "DataItem Filtering expression should not contain aggregate functions"

I can create an additional column on the table and use the RowNumber function, but the filters only allow you to use expressions or fields from the datasource, not columns that have been added to the table.

Thanks,
Derek

0
Katia
Telerik team
answered on 02 Dec 2016, 07:42 AM
Hi Derek,

You can use RowNumber() function in Table's group properties -> Filters - check this screenshot

A sample report demonstrating this approach is also attached. It can be opened with Standalone designer R3 2016.


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Report Designer (standalone)
Asked by
Derek
Top achievements
Rank 1
Answers by
Katia
Telerik team
Derek
Top achievements
Rank 1
Share this question
or