Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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
MVP & Luminary
MVP & Luminary

Re: Manual data iteration problem in load script.

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
4 Replies
MVP & Luminary
MVP & Luminary

Re: Manual data iteration problem in load script.

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

Re: Manual data iteration problem in load script.

Please see the attached file

Not applicable

Re: Manual data iteration problem in load script.

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

Re: Manual data iteration problem in load script.

Yeah gwassenaar‌ is the champ.