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.

markgraham123
Valued Contributor

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.

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

Re: give sequence number in script

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

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

4 Replies
MVP
MVP

Re: give sequence number in script

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

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

markgraham123
Valued Contributor

Re: give sequence number in script

That was perfect John!!

ThanksSmiley Happy

antoniotiman
Honored Contributor III

Re: give sequence number in script

May be

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

Regards,

Antonio

MVP
MVP

Re: give sequence number in script

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