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: 
markgraham123
Specialist
Specialist

give sequence number in script

Hi all,

I'm trying to give sequence to the value of ID. Grouped by ID, for every Value i would like to give a sequence number - 1,2,3

No specific order. Just a sequence number for every instance grouped by ID.

Data:

IDValue
1P0132-9540
1P8594-123
1P213098-323
2P-9540
2P-123
2P-323

O/P:

  

IDValueSequence
1P0132-95401
1P8594-1232
1P213098-3233
2P32-95401
2P94-1232
2P98-3233

Any help is highly appreciated.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Assuming you're loading from your real data source in ID order:

LOAD *
,if(ID=previous(ID),peek(Seq)+1,1) as Seq

View solution in original post

4 Replies
johnw
Champion III
Champion III

Assuming you're loading from your real data source in ID order:

LOAD *
,if(ID=previous(ID),peek(Seq)+1,1) as Seq

markgraham123
Specialist
Specialist
Author

That was perfect John!!

Thanks:)

antoniotiman
Master III
Master III

May be

LOAD *,Autonumber(RowNo(),ID) as Sequence

Regards,

Antonio

johnw
Champion III
Champion III

Oooh, even better! Simpler, and not sensitive to the order of the data!