Discussion Board for collaboration on QlikView Scripting.
In the attached app I have used the Rank function to create a ranking for products sold. The highest total sales gets 1 and works its way down.
How can I create the same type of field but in the script?
I realise there is no Rank function in the script so want to know how to do it
Go to Solution.
You may have another AutoNumber in your application which might be affecting that behavior. Try this:
AutoNumber(TotalSales, 'Rank') as Rank
Note: I cannot run the script because I don't have the source files, but try out the below code:
If(LineSalesAmount <50, 'Less than 50', 'Over 50') as 'Sales Check'
Sum(LineSalesAmount) as TotalSales
Group By %Key_Products;
AutoNumber(TotalSales) as Rank
Order By TotalSales desc;
DROP Table Temp;
Employees_ID as %Key_Employees,
(biff, embedded labels, table is Employees$);
This looks good. When I try and apply the same type of code to another app, the result of my AutoNumber does not start at 1. It starts at some other number.
I think this is because I am already using AutoNumber function in another field. If I use AutoNumberHash for example then it works because I am not using AutoNumberHas in another place.
Do you know how I can get it to start at 1?
That works! Can you please tell me why AutoNumber does this? I wasn't aware that if I used AutoNumber before, a new autonumber field add on top of those values.
Also what is the second parameter in your AutoNumber doing?
Second parameter is an ID which tells it that this is a different AutoNumber.
Why it does it, I have no idea. May be we can seek hic expertise on this.
Thank you so much for your explanation friend. I have learnt something new today.
I am glad I was able to share my knowledge with you
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