Skip to main content
Announcements
New: No-code data prep in Qlik Cloud Analytics™ TAKE A TOUR
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Ranking in the script

Hi Everyone-

I am trying to create scenario in the script that ranks the top 10 departments (DEPT) based on overtime hours worked (OT HOURS).  I'd like to create a variable for each department, 1 through 10.  My goal is to take these variables and use them in my set analysis to say, for example ..... < DEPT = { 'Rank3' } > } .....

Any suggestions?

Thanks!

Mike

4 Replies
MK_QSL
MVP
MVP

Can you provide sample data?

Simple script to get TOP in script can be done as below....

Temp:

Load * Inline

[

  Customer, Sales,

  A, 100

  B, 80

  C, 30

  D, 300

  E, 140

  F, 60

  A, 40

  C, 80

  D, 20

  E, 30

];

NoConcatenate

Temp2:

Load Customer, SUM(Sales) as [Total Sales]

Resident Temp

Group By Customer;

Drop Table Temp;

NoConcatenate

Final:

FIRST 3

Load * Resident Temp2;

Drop Table Temp2;

Not applicable
Author

I have two tables that I am using for the chart...  Table 1 contains DEPT and EmployeeID.  Table 2 contains EmployeeID and OTHOURS.  To get the total OTHOURS, I am calculating (in the dashboard) the SUM(OTHOURS) for each Employee.  So, using teh suggested script will not work.

I'd like to rank the top 10 DEPT's by OTHOURS worked.  Again, ranking them into a variable in the script to call on that variable in my set analysis.  Just not sure how to do it.

MK_QSL
MVP
MVP

Can you provide sample data?

Not applicable
Author

Here is a sample