Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
martynlloyd
Contributor III

Ranking in script

Does anyone have an example of ranking a list (example Customer, Sales), in the script?

EG

Customer     Sales     Rank

ABC              1000      2

DEF               1200     1

XYZ               900        3

Regards

Marty.

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

Re: Ranking in script

with an order by ?

a:

load * inline [

Customer,     Sales,     Rank

ABC     ,         1000 ,     2

DEF     ,          1200,     1

XYZ     ,          900 ,       3

];

b:

load *, rowno() as newrank

Resident a

order by Sales desc;

3 Replies

Re: Ranking in script

Hi,

Yes you can do in load script with Autonumber and order it desc by sales

Data:

LOAD * INLINE [

    Customer, Sales

    ABC, 1000

    DEF, 1200

    XYZ, 900

    eeee, 2300

];

NoConcatenate

FinalTable:

LOAD

Customer, Sales,AutoNumber(Sales) as RankNew Resident Data Order By Sales desc;

DROP Table Data;

Rank in Script.png

Regards

Anand

MVP
MVP

Re: Ranking in script

with an order by ?

a:

load * inline [

Customer,     Sales,     Rank

ABC     ,         1000 ,     2

DEF     ,          1200,     1

XYZ     ,          900 ,       3

];

b:

load *, rowno() as newrank

Resident a

order by Sales desc;

hugmarcel
Contributor III

Re: Ranking in script

Hi

see my example file rank.qvw.

- it contains a sub providing flexible ranking mechanisms,
  such as ranking by autonumber or by row().
- ranks can be split into half ranks for identical values
  (e.g. rank 11,12,13 -> 12, 12, 12)

https://community.qlik.com/docs/DOC-13949

Regards - Marcel

Community Browser