Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rvijayanth
Creator
Creator

How to add a sub sequence number during data load

I have like below: 

How do I generate "Sub Seq" which is sequence number grouped by the ID (for each ID). I like it to start from 1 and go till n number of date values that exist for that ID. 

IDDateSeqSub Seq
1D111
1D222
1D333
2D141
2D252
2D363
2D474
3D181
3D292
1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

A slight issue with your brackets

Change it to

If(IsNull(peek('ID', -1)) or ID <> peek('ID', -1), 1, peek('SubSeq', -1) + 1) as SubSeq

 

View solution in original post

6 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

LOAD

ID,

Date,

Seq,

If(IsNull(peek('ID', -1) or ID <> peek('ID', -1), 1, peek('Sub Seq', -1) + 1) as [Sub Seq]

RESIDENT [Your Table]

ORDER BY ID, Seq;

 

edit: added closing quote around second peek

rvijayanth
Creator
Creator
Author

Did you mean? (Seq)

If(IsNull(peek('ID', -1) or ID <> peek('ID, -1), 1, peek('Seq', -1) + 1) as [Sub Seq]

marcus_malinow
Partner - Specialist III
Partner - Specialist III

No, I meant Sub Seq

rvijayanth
Creator
Creator
Author

Sorry not working: 

This is what I have: 

If(IsNull(peek('ID', -1) or ID <> peek('ID', -1)), 1, peek('SubSeq', -1) + 1) as SubSeq

marcus_malinow
Partner - Specialist III
Partner - Specialist III

A slight issue with your brackets

Change it to

If(IsNull(peek('ID', -1)) or ID <> peek('ID', -1), 1, peek('SubSeq', -1) + 1) as SubSeq

 

rvijayanth
Creator
Creator
Author

Thanks. It worked now.