Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
EliAttiaQlik
Contributor II
Contributor II

rank of individual among others

Hi folks,

Is it possible.

According to the first attached table, the user would like to know the ranking of a student in each class.
For example, if Joe is chosen, then in English class he is in fourth place out of seven, in French class he is in third place out of five and so on (see below table).

The Qlk should mark the appropriate cell accordingly

10Q

 

 

School Class Student Grade
North English Joe 61
North English Lin 19
North English Mark 7
North English Daniel 78
North English George 48
North English David 78
North English Lucy 99
North French George 11
North French Mark 69
North French Joe 21
North French Lin 4
North French David 22
North Italian Elthon 17
North Italian Tom 37
North Italian Joe 5
North Italian Aritha 74
North Italian Barak 17
North Italian Jimmy 51
East Arabic Lin 52
East Arabic Daniel 56
East Arabic Mark 6
East Arabic Joe 23
East Spanish George 84
East Spanish Lin 79
East Spanish Joe 27
East Spanish Elthon 78
East Spanish David 61
East Portuguese Aritha 14
East Portuguese Tom 79
East Portuguese Joe 40
East Portuguese Mark 74
East Portuguese Jimmy 43
East Portuguese Barak 5
East Portuguese Lulu 95

 

 

English 1 2 3 4 5 6 7
French 1 2 3 4 5    
Italian 1 2 3 4 5 6  
Arabic 1 2 3 4      
Spanish 1 2 3 4 5    
Portuguese 1 2 3 4 5 6 7

 

 

 

Labels (4)
1 Solution

Accepted Solutions
theoat
Partner - Creator III
Partner - Creator III

For the rank in the english class, try this :

aggr(rank(sum({Class = {"English"}Grade))Student)

 For the rank in the french class, try this :

aggr(rank(sum({Class = {"French"}Grade))Student)

You can add this measure in the table. Add a show condition in this table :

GetSelectedCount(Student) = 1


Enjoy your Qlik.

Kind regards,
Théo ATRAGIE.

View solution in original post

6 Replies
pravinboniface
Creator II
Creator II

Are you open to assigning the rank in the load script?

 

// Load the data
Grades:
load * inline [
School,Class,Student,Grade
North,English,Joe,61
North,English,Lin,19
North,English,Mark,7
North,English,Daniel,78
North,English,George,48
North,English,David,78
North,English,Lucy,99
North,French,George,11
North,French,Mark,69
North,French,Joe,21
North,French,Lin,4
North,French,David,22
North,Italian,Elthon,17
North,Italian,Tom,37
North,Italian,Joe,5
North,Italian,Aritha,74
North,Italian,Barak,17
North,Italian,Jimmy,51
East,Arabic,Lin,52
East,Arabic,Daniel,56
East,Arabic,Mark,6
East,Arabic,Joe,23
East,Spanish,George,84
East,Spanish,Lin,79
East,Spanish,Joe,27
East,Spanish,Elthon,78
East,Spanish,David,61
East,Portuguese,Aritha,14
East,Portuguese,Tom,79
East,Portuguese,Joe,40
East,Portuguese,Mark,74
East,Portuguese,Jimmy,43
East,Portuguese,Barak,5
East,Portuguese,Lulu,95
];

// Rank students within a given school & class
Left Join
load School, Class, Student, 
	  AutoNumber(Grade, School&Class) as Rank
Resident Grades
order by School, Class, Grade desc;

exit Script;

 

pravinboniface
Creator II
Creator II

Just realized I had an error.  I updated the line above.

AutoNumber(Grade, School&Class) as Rank

EliAttiaQlik
Contributor II
Contributor II
Author

Thank you,

The question is whether it can be done in real time. The user selects a student and the click displays the student's rank in each of the class.
Thank you

pravinboniface
Creator II
Creator II

Please try with this measure formula with the table to show the rank

aggr(rank(sum({1}Grade)), School, Class, Student)

 

theoat
Partner - Creator III
Partner - Creator III

For the rank in the english class, try this :

aggr(rank(sum({Class = {"English"}Grade))Student)

 For the rank in the french class, try this :

aggr(rank(sum({Class = {"French"}Grade))Student)

You can add this measure in the table. Add a show condition in this table :

GetSelectedCount(Student) = 1


Enjoy your Qlik.

Kind regards,
Théo ATRAGIE.

EliAttiaQlik
Contributor II
Contributor II
Author

excellent and out of the box approach.