Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
deepakqlikview_123
Specialist

Top n vs bottom n records

Hello Experts,

Please find attached screenshot can you please tell me how shall I get Top n and bottom n records as shown in attached sceenshot.

Thanks,

2 Replies
whiteline
Master II

Hi.

You can use either rank() function in expressions or dimension limits tab in preferences.

MK_QSL
MVP

Let you have below dummy script..

=================

Load * Inline

[

  Customer, Sales

  A, 120

  B, 80

  C, 90

  D, 100

  E, 200

  G, 210

  H, 150

];

=====================

You want top 2 and bottom 2 customers in your straight table..

Dimension

Customer

Expression

SUM({<Customer = {"=Rank(SUM(Sales),4)<=2 or Rank(-SUM(Sales),4)<=2"}>}Sales)

You can also use below as an expression where vTOP and vBOTTOM are your variable

Create an input box for vTOP and vBOTTOM .... and use below as an expression.

Hope this helps..

SUM({<Customer = {"=Rank(SUM(Sales),4)<=$(vTOP) or Rank(-SUM(Sales),4)<=(vBOTTOM)"}>}Sales)