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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
QS21
Creator
Creator

MIN3 and MAX3 values in qliksense

Hi all,

I am trying to get Max3 employees month on month in a bar chart.

X-axis=Months and bars on each month will have 3 employees who came in top3 that month.

I used sum({<EMPLY_NAME={"=rank(aggr(Sum(Sales), EMPLY_NAME), 4, 1)<=3"}>} Sales) which is working perfectly.

Now the problem is with MIN3, I used

sum({<EMPLY_NAME={"=rank(aggr(-Sum(Sales), EMPLY_NAME), 4, 1)<=3"}>} Sales)  I used - infront of sum to get the reverse rank which seems fine but there are'-' NULLs in the sales column. so I getting the employee names with null in the MIN3 chart. I tried many conditions to exclude them but no use.

Someone pls suggest how to get the bottom3 employees whoc are not NULL.

 

Thanks in advance!

3 Replies
justISO
Specialist
Specialist

Hi, maybe with

sum({<EMPLY_NAME={"=rank(aggr(if(not isnull(Sales),-Sum(Sales)), EMPLY_NAME), 4, 1)<=3"}>} Sales)

QS21
Creator
Creator
Author

Hi, I have tried it and am still not getting the result:

QS21_0-1658310495702.png

 

 

justISO
Specialist
Specialist

I believe your max3 then not working properly too, because your ranking employees total sales (not per each month) and representing those top3 employees sales, not searching top3 employees by sales each month. So you should aggregate not by Employee only, but by Date too, something like this aggr(Sum(Sales), DATE, EMPLY_NAME).

How I would calculate min3 (as I'm not very friendly with set analysis :/):

if(Aggr(Rank( if(sum(Sales)<>0,-Sum(Sales)) ),DATE,EMPLY_NAME) <= 3, Sum(Sales),Null())

and in Add-ons->Data handling uncheck 'Include zero values'