Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
CUSTOMERS ONLY: Now accepting customer applications for the 2023 Luminary Program: SUBMIT NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rajeshqvd
Creator II
Creator II

rank in script

Hello i am getting Count need Rank output thanks advance

IDColor CountRank
111blue44
111   
111blue43
111   
111   
111blue42
111   
111blue41
222   
222red33
222red32
222red31
222   
Labels (1)
1 Solution

Accepted Solutions
avkeep01
Partner - Specialist
Partner - Specialist

Right, no problem. 

 

Sort you table based on your count and then add: 

IF(ROWNO()=1,1,PEEK('Rank',-1)+1) AS Rank

It peeks at the previous rows and adds 1 to that number. When sorted at the correct count field you'll get a Rank. 

If you want to start a new count for every ID use this: 

IF(PEEK('ID',-1)<>ID,1,PEEK('Rank',-1)+1) AS Rank

View solution in original post

3 Replies
avkeep01
Partner - Specialist
Partner - Specialist

Hi @rajeshqvd

Basically you can start with: 

RANK(COUNT(Count))

The next step is using aggregates over color or ID, depending on what you need. 
For example: 

AGGR(RANK(COUNT(Count)),ID)

But based on the column count you won't get far because all the values are the same per ID. 

rajeshqvd
Creator II
Creator II
Author

Need to build it in Script Not front end
avkeep01
Partner - Specialist
Partner - Specialist

Right, no problem. 

 

Sort you table based on your count and then add: 

IF(ROWNO()=1,1,PEEK('Rank',-1)+1) AS Rank

It peeks at the previous rows and adds 1 to that number. When sorted at the correct count field you'll get a Rank. 

If you want to start a new count for every ID use this: 

IF(PEEK('ID',-1)<>ID,1,PEEK('Rank',-1)+1) AS Rank