Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank function in expression

Hi,

Anybody know how I should change the Rank formula using to get right result for the same values.

I'm using the following as a dimension- Aggr(Rank(Sum(Value),1,1),ID)

t1.png

But I'm trying to get the following:

t2.png

Is it possible to gain above result?

1 Solution

Accepted Solutions
whiteline
Master II
Master II

As I said use my expression for sort order:

=Aggr(Rank(Sum([Revenue (KSEK)]),1,1),Client)

and this as dimension instead of Client(to limit first 30):

=aggr(if(Rank(total Sum([Revenue (KSEK)]))<=30, Client), Client)

and check 'Suppress When Values Is Null'.

View solution in original post

17 Replies
whiteline
Master II
Master II

I've found this workaround:

Use your rank expression (=Aggr(Rank(Sum(Value),1,1),ID)) as a Sort expresion for ID dimension.

Delete your calculated dimension.

Add expression =rowno() and lable it 'Rank'.

Seems exactly as you want.

Not applicable
Author

Thank you for solution, but it is not working in my case.

I need show only top 30 client by revenue amount. There some problem with right ordering.

whiteline
Master II
Master II

As I said use my expression for sort order:

=Aggr(Rank(Sum([Revenue (KSEK)]),1,1),Client)

and this as dimension instead of Client(to limit first 30):

=aggr(if(Rank(total Sum([Revenue (KSEK)]))<=30, Client), Client)

and check 'Suppress When Values Is Null'.

Not applicable
Author

Thanks, it works.

But if I want to do the same with Chart can I use the same method?

whiteline
Master II
Master II

Yes, I think you can.

The menthod is just 'calculated dimension'.

Not applicable
Author

I need to keep the rank as a dimension. Actually, I need rank as a normalized value between 0 and 1.

How to achieve this?

whiteline
Master II
Master II

=Aggr(Rank(Sum([Revenue (KSEK)]),1,1),Client)/Count(distinct Client)

=aggr(if(Rank(total Sum([Revenue (KSEK)]))<=30, Client), Client)/30

Not applicable
Author

Whiteline,

Please refer to the original post. I have the same issue. ID has duplicate values, but I still need unique ranks as part of the dimension.

whiteline
Master II
Master II

And what is the problem with the expressions provided above ?