Discussion Board for collaboration on QlikView Scripting.
I am trying to rank item within a group, see below example, add a new column Rank to count the order of Cat_2 which in the same group of Cat_1. Then I can just select rank=1, to get a 1 to1 mapping table between Cat_1 and Cat_2
Can I fulfil this in a loading script?
Thanks a lot!
Go to Solution.
AutoNumber(Cat_1&Cat_2,Cat_1) as Rank
If you are ranking by load order in the script. then something like this should work:
If(Cat_1 = Previous(Cat_1), Peek(Rank) + 1, 1) As Rank
Order By Cat_1;
If you need to order by value in Cat_2, for example, add this to the order by:
Order By Cat_1, Cat_2;
AutoNumber(RecNo(), Cat_1) as Rank
That's a clever use of AutoNumber()!
I know its already solved but i figured out one more way to do it.
I created an expression in a straight table as
brilliant idea, Shashi! Tks
see my example file rank.qvw.
- it contains a sub providing flexible ranking mechanisms, such as ranking by autonumber or by rowno().- ranks can be split into half ranks for identical values (e.g. rank 11,12,13 -> 12, 12, 12)
Regards - Marcel