Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank for table

I have a dimension country.

I want to know for each country in a table, which is the top product with sum(sales)

It should look like this:

Country     Product

Mexico          A

England         B

USA              C

France           A

I tried with:

I tried combining if, rank and aggr but with no luck yet.

Any ideas?

Regards

Federico

1 Solution

Accepted Solutions
Not applicable
Author

The solution is:

=Aggr(if(Rank( Sum(Sales))=1,  Product),Country,Product)


Didn't know that the order matter, I had already tried =Aggr(if(Rank( Sum(Sales))=1,  Product),Product,Country)

View solution in original post

4 Replies
Not applicable
Author

This is my last idea, but only shows the ranked 1 product disregarding the country

(In a table with country as dimension)

=Aggr(if(Rank( Sum(Sales))=1, Product),Product)

Not applicable
Author

The solution is:

=Aggr(if(Rank( Sum(Sales))=1,  Product),Country,Product)


Didn't know that the order matter, I had already tried =Aggr(if(Rank( Sum(Sales))=1,  Product),Product,Country)

Not applicable
Author

Try without the IF condition and with Rank out of Aggr function:

Rank(Aggr(Sum(Sales), Product))

I hope this help you.

Luciano.-

Not applicable
Author

Hi Luciano. Found the answer.

You solution returns numbers when I need text values.