Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Manual data iteration problem in load script.

Hello!

I am having a problem with ranking data as per my needs.

I tried in SQL directly and with use of QV functions.

I want to achieve rank as per below example

Employee

TypeWeekRank
A1101
A1111
A2122
A1133
B3101
B2112
B3123
B2134
B2144

1. Rank should reset for next employee (row 5)

2. When Type is the same continuously, week by week, Rank stays the same. (rows 1 & 2)

2. When Type changes, rank changes as well (row 3)

3. When same Employee and Type combination is occurring again, but not as continuation, Rank must change (row 2 & 4, as was divided by different type in row 3

How to achieve that?

Regards!

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try:

LOAD

     Employee,

     Type,

     Week,

     if(Previous(Employee)=Employee,if(Previous(Type)=Type,peek(Rank),rangesum(1,peek(Rank))),1) as Rank

FROM ...


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Try:

LOAD

     Employee,

     Type,

     Week,

     if(Previous(Employee)=Employee,if(Previous(Type)=Type,peek(Rank),rangesum(1,peek(Rank))),1) as Rank

FROM ...


talk is cheap, supply exceeds demand
Kushal_Chawda

Please see the attached file

Not applicable
Author

Big thanks to both of you! Both solutions are correct Marking Gysbert's one as correct as he was faster.

Kushal_Chawda

Yeah gwassenaar‌ is the champ.