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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Grouping customers per rating

Hi all,

I am facing a little problem, but I can't find a solution.

I have a customers table with the key "C_ID" and a linked sales table (including the amount "SaleAmount"), and I dinamically need to calculate a rating per customer using a variable, and it works. What I am not able to do is to show a linear table with grouping per range of rating and showing the count of C_ID. Example:

the variable "ratingExpr" has value "sum(SaleAmount)"

and I show the rating of every customer with $(=$(ratingExpr))

the resulting table should look like this:

rating                                    | count

-----------------------------------------------------

less than 10.000                    | 15

between 10.001 and 20.000    | 28

more of 20.000                       | 9

How can I achieve this? By using Aggr() ? If yes, could you please explain me how to do?

Thank you in advance

Carlo A. Babini

1 Solution

Accepted Solutions
whiteline
Master II
Master II

Hi.

Have you tried calculated dimension ?

You coul use expression as 'rating' dimension, for example:

=aggr(if(rank(sum(SaleAmount))<10000, 'less than 10.000', 'more than 10.000 or equal') , C_ID)

View solution in original post

4 Replies
whiteline
Master II
Master II

Hi.

Have you tried calculated dimension ?

You coul use expression as 'rating' dimension, for example:

=aggr(if(rank(sum(SaleAmount))<10000, 'less than 10.000', 'more than 10.000 or equal') , C_ID)

Not applicable
Author

Hi,

I'm sorry but I was not able to try your suggestion before today, but... it just works for me!

Thank you so much, but could you please explain me how does Rank() function works? I tried to undersand the manual page but it is not that easy for me.

Thank you

Carlo A. Babini

MayilVahanan

Customer

Sum(Amount)Rank Value
XXX2003
YYY1004
ZZZ10002
XYZ10101

Hi

From the above table, you can find , rank function gives the number based on higher value..

So, if we used like this, =if(rank(sum(Amount)) <= 2, 'Less than 3','More than 3')

for customer : zzz,xyz display Less than 3

                       xxx,yyy display More than 3

I think you will understand the concept..

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Yes, now it is a little clearer

Thank you

Carlo A. Babini