Top N Filter TieBreak

4 posts, 0 answers
  1. Derek
    Derek avatar
    7 posts
    Member since:
    May 2015

    Posted 29 Nov 2016 Link to this post

    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

     

  2. Katia
    Admin
    Katia avatar
    693 posts

    Posted 30 Nov 2016 Link to this post

    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
  3. Derek
    Derek avatar
    7 posts
    Member since:
    May 2015

    Posted 01 Dec 2016 in reply to Katia Link to this post

    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

  4. Katia
    Admin
    Katia avatar
    693 posts

    Posted 02 Dec 2016 Link to this post

    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
Back to Top