Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to number SubField results?

I need to number the SubField() function results so you can identify each part individually, see the code:

Source:

Load * Inline [

Id, Text

1, ‘part a,part b,partc’

2, ‘part a,part d,part e’

];

SubFields:

Load Id,

SubField(Text,’,’) as SubText,

magicfunction() as Order

Resident

                Source;

Expected result:

Id     SubText     Order

1     part a          1

1     part b          2

1     part c          3

2     part a          1

2     part d          2

2     part e          3

Right now I'm using RecNo() generating secuential number but gives me huge numbers for the last records.

Any idea what magicfunction() can be?

Thank you!

Enrique.

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

The magic function is IterNo(), but you need to use a While loop:

SubFields:

Load Id,

     SubField(Text,',',IterNo()) as SubText,

     IterNo() as Order

     Resident Source

               While IterNo() <= 1+Len(KeepChar(Text,','));

HIC

View solution in original post

2 Replies
hic
Former Employee
Former Employee

The magic function is IterNo(), but you need to use a While loop:

SubFields:

Load Id,

     SubField(Text,',',IterNo()) as SubText,

     IterNo() as Order

     Resident Source

               While IterNo() <= 1+Len(KeepChar(Text,','));

HIC

Not applicable
Author

Hernic thank you very much, it worked like a charm!