Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
kadzema
Contributor
Contributor

Sort not working as expected with rank

I have applied ranking of sum(sales) by item. There are some products in more than one category (Product F below). The ranking seems to be arbitrarily applied to the product in the category with lower sales and is displaying that product first when I sort by rank ascending and then product sales desc.

kadzema_0-1706624205733.png

If i change the sort to product sales desc and then rank I get the below which then doesn't show the rank where i would like to see it:

kadzema_1-1706624409452.png

Here is what I would like to see:

kadzema_2-1706624491990.png

Note that with my small sample data, I am seeing the expected results. 

What could be happening to cause this and how can I fix it?

Many thanks!

 

 

Labels (1)
1 Solution

Accepted Solutions
LRuCelver
Partner - Creator III
Partner - Creator III

If you want the ranking to be calculated over all products and categories, you can use Aggr() with both dimensions:

LRuCelver_0-1706708713639.png

Aggr(Rank(total ProductSales, 4), Product, Category)

 

View solution in original post

2 Replies
LRuCelver
Partner - Creator III
Partner - Creator III

If you want the ranking to be calculated over all products and categories, you can use Aggr() with both dimensions:

LRuCelver_0-1706708713639.png

Aggr(Rank(total ProductSales, 4), Product, Category)

 

kadzema
Contributor
Contributor
Author

Thank you @LRuCelver - adding total was the key! without, each product had it's own rank. My understanding is that aggregate is saying to use these dimensions and total says to ignore the dimensions. Can you please break down for me in pseudocode how this is interpreted?