Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I add a rank field in a load script statement?

Hi All,

I am using the code below to derive a Count field. Is it possible to add a rank for each TechArea2 as a seperate field based on the Count?

Load TechArea2 , count(DISTINCT [Sl. No]) as Count

Resident ABC

Group by TechArea2;

So I want something like for the TechArea2 with the highest count the rank would be 1, then 2,3,4... and so on. I had used a rank() function in the chart but I have to derive this field in the load statemnet.

Can anyone please suggest anything?

Thanks in advance.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this should do it:

T1:

Load TechArea2 , count(DISTINCT [Sl. No]) as Count

Resident ABC

Group by TechArea2;

T2:

load TechArea2, Count, rowno() as Rank

resident T1 order by Count desc;

drop table T1;


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this should do it:

T1:

Load TechArea2 , count(DISTINCT [Sl. No]) as Count

Resident ABC

Group by TechArea2;

T2:

load TechArea2, Count, rowno() as Rank

resident T1 order by Count desc;

drop table T1;


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert. that was a nice trick.

thanks again.