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: 
jokelaa
Contributor
Contributor

Rank function

Hi!

If I have a table showing dimension and a measure (lets say Store and sales)

I want to add ranking for each store based on sales. 

This is easy.

But what is the formula for set analysis if I want to add a KPI showing this ranking number for a selected store based on the whole data set. 

Everything I have tried returns 1 since the data is showing sales for this single store.

Labels (1)
2 Solutions

Accepted Solutions
tresesco
MVP
MVP

You have to disregard the selection (use set analysis) to bring all the stores so that the rank can be calculated against all stores. If you are trying this in a text/kpi object, try like:

Aggr(Rank(Sum({1}Sales)), Store)      // or {<Store>} instead of '{1}'

If in a chart, you might not need aggr.

View solution in original post

tresesco
MVP
MVP

The second option mightn't not work if you have other selections as well. 

View solution in original post

3 Replies
tresesco
MVP
MVP

You have to disregard the selection (use set analysis) to bring all the stores so that the rank can be calculated against all stores. If you are trying this in a text/kpi object, try like:

Aggr(Rank(Sum({1}Sales)), Store)      // or {<Store>} instead of '{1}'

If in a chart, you might not need aggr.

jokelaa
Contributor
Contributor
Author

Thank you!!

I was on the right track and had tried the other one you suggested. For some reason that one does not work but the other one did. Can you explain why is this so 🙂

Below pics for both versions. The one above works but the one below does not.

What am I missing?

Location is our version of store

 

jokelaa_0-1683199065907.png

 

tresesco
MVP
MVP

The second option mightn't not work if you have other selections as well.