Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for
Did you mean:
Not applicable

## Display top 3 customers

hi,

I want to get top 3 customers based on total balance(deposit column - withdrawl column) I have used Rank function where em getting all ranks based on total balance. Where highest balance takes highest rank number.

Ex: 10 refers to highest total balance.

I have used      below code in expression

Rank((Deposit_Amt - Withdrawl_Amt),4,0)

How can I refine it to get top 3 based on highest bal?

Regards,

Prajna

1 Solution

Accepted Solutions
Specialist

If(AGGR(Rank((Deposit_Amt-Withdrawl_Amt)),Customer)<=3,Customer)

13 Replies
Specialist

Rank(Expression)<=3

Not applicable
Author

Hi,

I had tried that but it doesn't work.. can u tell me what expression refers to

I Tried

Rank ((Deposit_Amt - Withdrawl_Amt),4,0)<=3

as well as

Rank((Deposit_Amt - Withdrawl_Amt)) <=3

earlier..

Regards,

Prajna

Specialist

If(AGGR(Rank((Deposit_Amt-Withdrawl_Amt)),Customer)<=3,Customer)

Not applicable
Author

Hi Try This,

=aggr(if(rank(sum(Deposit_Amt-Withdrawl_Amt))<=3,Customer),Customer)

Not applicable
Author

Hi,

This works fine.. but how can I get rank in display in my chart like 1,2,3 for top 3? where 1 is the highest?

Regards,

Prajna

Not applicable
Author

Hi,

This gives wrong result

As suggested this works fine

Rank (AGGR(Rank((Deposit_Amt-Withdrawl_Amt)),Cust_Id)<=3,Cust_Id)

but it doesn't display rank value

Regards,

Prajna

Specialist

Just sort it
Suppose your expression name is Top3Customers so go to sort and under Numeric show ascending or descending

Not applicable
Author

The customer specified in the code

If(AGGR(Rank((Deposit_Amt-Withdrawl_Amt)),Customer)<=3,Customer)

cant it be customer name any constraint like return type should be int as we have agg ?And one more thing cant I get a display like Rank 1, Rank 2, Rank 3.

Regards,

Prajna

Specialist

Try using 'Rank'&Autonumber(Customers) as Rank

Community Browser