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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
AnneM
Contributor II
Contributor II

Rank : adding product code dimension makes all ranks = 1

Hi,

I made a table ranking the sum of sales revenue for each month per product name and it works well.

I was asked to add the product code dimension to the table, but when I do all my ranks turn to 1.

here is the formula I'm using :

 

=rank(sum({$ <Mois = {'janv.'}>}[Montant HT])) 

 

 here is what the table looks like once I've added the product code :

AnneM_0-1686839981467.png

Thanks !

 

Edit : I've tried =rank(TOTAL sum({$ <Mois = {'janv.'}>} [Montant HT])) and it works but I need the ranks by "family products", where can I add this, something like <"family products"> ?

Labels (2)
1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi AnneM,

The Rank() function ranks the most detailed (the last) dimension in the chart, within the context of the previous dimension - this is why all Ranks turned to 1 once you added another dimension.

You can do one of the following:

1. You can turn the Code Product (or the Product Description) into a Measure, like this:

     only([Code Product])

2. Or, you can add the keyword TOTAL to your Rank() function:


 

=rank(total sum({$ <Mois = {'janv.'}>}[Montant HT])) 

 

 

One of these two solutions should solve the problem.

Cheers,

View solution in original post

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi AnneM,

The Rank() function ranks the most detailed (the last) dimension in the chart, within the context of the previous dimension - this is why all Ranks turned to 1 once you added another dimension.

You can do one of the following:

1. You can turn the Code Product (or the Product Description) into a Measure, like this:

     only([Code Product])

2. Or, you can add the keyword TOTAL to your Rank() function:


 

=rank(total sum({$ <Mois = {'janv.'}>}[Montant HT])) 

 

 

One of these two solutions should solve the problem.

Cheers,

AnneM
Contributor II
Contributor II
Author

amazing thank you ! I used the first solution (the second one didn't correspond as I wanted to rank by products' family), and thank you for the explanation of why the ranks were equals to 1