Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank func

Hello ,

I want to use rank func and need to found the first 10 best sal usig rank func

and emp table has emp_id , sal .

can any one help me ???

2 Replies
swuehl
MVP
MVP

Try creating a straight table with dimension emp_id and as expression:

sum({<emp_id ={"=rank(sum(sal))<=10"}>} sal)

This should filter your Top 10 Employees by Sales amount. (Another approach would be to just use sum(sal) as expression, sort your table by the expression, numerical desc and then limit your table to first 10 lines in dimension limits tab. But since you asked for rank function...)

Hope this helps,

Stefan

Anonymous
Not applicable
Author

The major difference between limiting table to the first 10 lines and using rank is that in the first case the total line (if you're using it) does not exclude results for the ranks>10.  So, using rank makes sense.
Next, I prefer to use it in dimension, replacing emp_id with calcualted dimension:

=aggr(only({<emp_id={"=rank(sum(sal))<=10"}>} emp_id),emp_id)
(make sure to check "suppress if value is null")

It helps in case you have multiple expressions, and want to rank by one of them.

Regards,
Michael