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

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

Rank Between Values

Hi, I'm new to Qlikview and need help with a rank function.  I'm trying to rank between values.  For example, the store Ranking is from 1 to 391 based on YTD Sales.  I would like to see the total YTD Sales for the stores ranked between 50 and 100.  I was trying the following but obviously I'm missing something.

=aggr(if(Rank(sum([YTD POS Sales]))<=50and(sum([YTD POS Sales]))>=100,[Store Nbr]),[Store Nbr])

Thank you in advance!

11 Replies
maxgro
MVP
MVP

=

sum(aggr(

     if(aggr(rank(sum([YTD POS Sales])),[Store Nbr])>=50

     and aggr(rank(sum([YTD POS Sales])), [Store Nbr])<=100,

sum([YTD POS Sales])), [Store Nbr]))

vgutkovsky
Master II
Master II

Massimo's expression should work, but it's a bit heavy because of the extra aggrs. Here's one that's a little lighter and does the same thing with 1 aggr:

sum(aggr(

       if(rank(sum([YTD POS Sales]),4,1)>=50 and rank(sum([YTD POS Sales]),4,1)<=100,sum([YTD POS Sales]))

       ,[Store Nbr]

))

Regards,

Vlad

maxgro
MVP
MVP

yes, there is an extra aggr in my expr, thanks Vlad

Not applicable
Author

Thank Guys.  It says the expression is okay but the chart body says "Allocated memory exceeded".  Any idea how to fix that? 

Thanks again.

vgutkovsky
Master II
Master II

Which version of the expression are you using?

Not applicable
Author

The one you provided.

vgutkovsky
Master II
Master II

How many stores are in your data? And are you reducing the data through selections or trying to calculate over all data)?

Not applicable
Author

There are 391 stores in the data and calculating over all ytd sales.

vgutkovsky
Master II
Master II

Hang on, I just reread you original question. Are you trying to do this with calculated dimensions? The dimension of the chart, using my expression above, should just be Store Nbr.

Alternatively, if you want to use calculated dimensions, you can created the following calculated dimension:

aggr(

       if(rank(sum([YTD POS Sales]),4,1)>=50 and rank(sum([YTD POS Sales]),4,1)<=100,[Store Nbr])

       ,[Store Nbr]

)

Make sure to check the "Suppress When Value is Null" checkbox. The expression of the chart would just be sum([YTD POS Sales])


Regards,

Vlad