Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

How to create pair in data using script

Hi,

I need to create pairs of values in data. I have a fied ID and i want to know how to get field Pair:


ID,Pair
a,1
a,1
a,2
a,2
a,3
b,1
c,1
c,1
d,1
d,1
d,2
e,1
e,1
e,2
e,2
e,3
e,3
e,4
f,1
f,1
f,2
.

.

That is, the 2 first occurences of a value with 1, the 3rd & 4rd, 2, and so on.

It has to be done in script so that I get the table above

Thanks a lot in advance

 

Labels (1)
2 Replies
Highlighted
Digital Support
Digital Support

Best I have for you is a link to the Design Blog area to see if you can find something there that may help:

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

There are hundreds of posts on things there, so you may have to try different things to find something that may help here if you are still working on things.  Sorry I do not have something better for you.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Highlighted
Specialist II
Specialist II

Try this

 

Temp:

load * , if( Peek(ID)<>ID ,1,peek(rows)+1) as rows , RowNo() as row  inline [

ID
a
a
a
a
a
b
c
c
d
d
d
e
e
e
e
e
e
e
f
f
f
];

 

load
ID,
rows,
row,
if(row=1 or Peek(ID)<>ID ,1 ,
if( Peek(ID)=ID and odd(rows)='-1', Peek(new)+1 , Peek(new) )) as new


Resident Temp
Order by row
;