Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
qliksunil
Partner - Contributor III
Partner - Contributor III

Cascaded Ranking in the Script

Hi All,

I have 2 fields in a table i want to rank each row based on alphabetically A-->Z letter.

The Data set is like this:

Load * Inline

[Client, Branch

Apple, Texas

Apple, Newyork

Apple, London

Beattle, Texas

Beattle, Munich

Orange, Boston

Orange, Callifornia

];

So in the script the resultant table will be

Client, Branch, Rank

Apple, Texas, 3

Apple, Newyork, 2

Apple, London, 1

Beattle, Texas, 2

Beattle, Munich, 1

Orange, Boston, 1

Orange, Callifornia, 2

Comments highly appreciated.

Labels (1)
1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Try this:

 

LEFT JOIN ([Your table])

LOAD

    Client,

    Branch,

    if(Client = peek('Client',-1),

        peek('Rank', -1) + 1,

        1) as Rank

RESIDENT [Your table]

ORDER BY Client, Branch

;

View solution in original post

2 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Try this:

 

LEFT JOIN ([Your table])

LOAD

    Client,

    Branch,

    if(Client = peek('Client',-1),

        peek('Rank', -1) + 1,

        1) as Rank

RESIDENT [Your table]

ORDER BY Client, Branch

;

qliksunil
Partner - Contributor III
Partner - Contributor III
Author

This works fine.

Thanks a lot for your valuable suggestions.