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

Advanced top 5 items by count

Hi,

I am tying to make a chart that shows the top 5 most populous colleges in a certain state (Minnesota). I have a variable called [States], a variable called [College Name], and a variable called [College Population]. What script can I use to do this?

Thanks,

1 Solution

Accepted Solutions
sasikanth
Master
Master

HI, 

Try to create one calculated dimension as below 

Dim1: [States]

Dime2: =if(Aggr(rank(sum( [College Population]),4),[States],[College Name])<=5,[College Name])

* check suppress null values.

 

Expression:

Sum([College Population])

 

Hope this helps,

Sasi

View solution in original post

5 Replies
Andrea_Bertazzo
Support
Support

Hi,

Please, have a look at this post:

https://community.qlik.com/t5/New-to-Qlik-Sense/To-show-top-5-values/td-p/1114961

This should answer your question.

 

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up ! 🙂
JustTryingToLearn
Contributor III
Contributor III
Author

Sorry, this is not what I am looking for - I am looking for the top 5 values only, not just to have the rest of the values hidden behind a scroll wheel. I am doing this because my requirements are to have these 5 values fit into a stacked bar chart - when using your method I have over 100 items in a single stacked bar.

Thanks,

sasikanth
Master
Master

HI, 

Try to create one calculated dimension as below 

Dim1: [States]

Dime2: =if(Aggr(rank(sum( [College Population]),4),[States],[College Name])<=5,[College Name])

* check suppress null values.

 

Expression:

Sum([College Population])

 

Hope this helps,

Sasi

JustTryingToLearn
Contributor III
Contributor III
Author

Thank you - you wouldn't happen to have a method to get a stacked 100% bar chart would you? I Tried to use Sum([College Population])/Sum(TOTAL <[States]> [College Population]) but it doesn't seem to work

sasikanth
Master
Master

HI, 

Your requirement is to display top 5 colleges for every state based on population measure. 

my previous response would work for the above scenario,

select stacked option in bar chart properties

output would be like below chart, 

Comm_1815259.PNG

 

do let me know if it is not what you are looking for

 

Thank, 

Sasi