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: 
Stars
Creator
Creator

Count If and Rank

I've read several posts from others about Count If functions and I can't quite find one that works for me.  I am trying to write an expression that will tell the user their rank out of x companies.  I can use a count function to determine how many companies are represented on the chart, but I cannot figure out how to get the rank portion to work.  I would be fine with using a count if function so I'm only counting companies that reported a higher number than the selected company, but I can't get that to work either.

Example.  Year = 2020.  Employees = # of employees reported.  Company = all the companies in the survey.

Company A:   5 employees
Company B: 10 employees
Company C: 15 employees
Company 😧 20 employees
Company E: 25 employees

For company C, they're the 3rd company of 5.  So I want to display: "3 of 5" when company C is selected.  Below is what I have.  I get the "of 5" portion, but I can't get the "3" part.  If I use (getfieldselections(Company)) in my equation, it just returns "1" for their rank.  Any ideas?  I'm sorry if this isn't explained well!

 

=(max({1<Year = {$(=Max(num#(Year ,'####')))}>} Aggr(rank(((

Sum({1<Question={"Employees*"}>}Response)

)),Company),Company,Year)))

& ' of ' &

(count({1<Year = {$(=Max(num#(Year ,'####')))}>} Aggr(((

Sum({1<Question={"Employees*"}>}Response)

)),Company,Year)))

3 Replies
Ksrinivasan
Specialist
Specialist

hi,

why cant rank the company at script level as Rank field,

then you can call in chart,

Ksrinivasan

 

Stars
Creator
Creator
Author

I don't understand what "call in chart" means - can you explain?  Thanks.

Ksrinivasan
Specialist
Specialist

hi,

Call is not a call function.

you may rank your customer in script itself,

so, Customer rank is always same for individual Company,

when ever you have selected customer in your filter (example if you have selected company C)

result is  " (Company Rank)" &' of ' & count (Company) 

3 is the rank for the Company C and Total no of company is 5

so, result is = 3 of 5,

thats it.

i hope you understood.

ksrinivasan.