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: 
dreweezy
Creator II
Creator II

top 5 bottom 5 syntax in expression

I've created 2 buttons which is Top 5 and Bottom 5 (using a variable). I have my expression created and it works for the most part. The problem is that it shows me 4 bars for top 5 and 3 bars for bottom 5. I was expecting it to give me 5 bars, hence the <=5 placed in the expression. Any ideas?

If(vTopBot=1,

Sum({< merchandise ={"=Rank(Sum( COST))<=5 "}>} COST ),
Sum({< merchandise ={"=Rank(-Sum( COST))<=5"}>} COST )

)

1 Solution

Accepted Solutions
Channa
Specialist III
Specialist III

if(aggr(rank(sum(COST)),merchandise )<=5,merchandise )

this will give top5 merchandise

 

 



Channa

View solution in original post

4 Replies
Channa
Specialist III
Specialist III

if(aggr(rank(sum(COST)),merchandise )<=5,merchandise )

this will give top5 merchandise

 

 



Channa
dreweezy
Creator II
Creator II
Author

Thank you. If I wanted to put both top and bot in the same formula would I do something like - 

if(aggr(rank(sum(COST)),merchandise )<=5,merchandise ), aggr(rank(-sum(COST)),merchandise )<=5,merchandise 

 

Channa
Specialist III
Specialist III

if(aggr(rank(sum(COST)),merchandise )<=5 or  aggr(rank(-sum(COST)),merchandise )<=5,merchandise )

 

try this 

Channa
Channa
Specialist III
Specialist III

=aggr(if(rank(sum(COST))<=5 or rank(-sum(COST))<=5,merchandise ),merchandise )

it should work

i am using this bro..

 

below one works for me

=aggr(if(rank(sum(CUSTOMS_VALUE_QAR))<=5 or rank(-sum(CUSTOMS_VALUE_QAR))<=5,COUNTRY_NAME_EN),COUNTRY_NAME_EN)

Channa