Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Numbering a Subfield within the original ID

Hey guys - hopefully a simple one.

I have the following data:

R_IDR_Text
1001Hello/How are you
1002Hello/How is it going/talk to me
1003Hello/why are you not talking/this is rude
1004This is terrible/customer/service

I'd like to subfield it as follows:

LOAD

R_ID,

Subfield(R_Text,'/') as R_Text

FROM etc.

However, I ALSO want to number each line, so the final data looks something like this:

R_IDR_TextR_TextLineNo
1001Hello1
1001How are you2
1002Hello1
1002How is it going2
1002talk to me3
1003Hello1

etc.

Any ideas? I tried with recno() and numsum() but couldn't get it working.

Thank you!

Alex

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

LOAD

R_ID,

Subfield(R_Text,'/') as R_Text,

Autonumber(recno(), R_ID) as R_TextLineNo

FROM etc.

edit: Same problem using Recno() here, but you can use RowNo():

Autonumber(RowNo(), R_ID) as R_TextLineNo

View solution in original post

4 Replies
swuehl
MVP
MVP

Try

LOAD

R_ID,

Subfield(R_Text,'/') as R_Text,

Autonumber(recno(), R_ID) as R_TextLineNo

FROM etc.

edit: Same problem using Recno() here, but you can use RowNo():

Autonumber(RowNo(), R_ID) as R_TextLineNo

Anonymous
Not applicable
Author

Hi Alex,

Try this:

Original:

LOAD

R_ID,

Subfield(R_Text,'/') as R_Text,

FROM etc...

Order by R_ID asc;

Last:

LOAD

     R_ID,

     R_Text,

     IF(Previous(R_ID) = R_ID, Peek(R_TextLineNo)+1,1) as R_TextLineNo

RESIDENT Original;

Regards!

Not applicable
Author

Genius.

Not applicable
Author

Thank you Manuel!