Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Splitting a field into multiple fields

Hi,

mayilvahanan

I have one query in this post.

Splitting a field into multiple fields

How can I use variable in this part for i=1 to 5 of the script?.. I want to make it for i =1 to max(test)... test is field in Tab2.

Tab2:

LOAD *,SubStringCount(Change1,'|') as test Inline [

Team1,Change1

A,10|20|30|40|50

];

for i=1 to 5

Tab23:

LOAD *, SubField(Change1,'|',$(i)) as fieldname$(i)

Resident Tab2 ;

NEXT i;

Labels (1)
4 Replies
marcus_sommer
MVP
MVP

If you used subfield within a load without the third parameter qlik will be automatically loop through them - this meant you don't need your extra outside loop.

- Marcus

sunny_talwar
MVP
MVP

Maybe Generic load once you have the data in different rows?

The Generic Load

Anonymous
Not applicable
Author

Is it possible in some way for i =1 to max(test).

I tried several combinations of Subfield, Concat. I am not getting what I need. With the script above I am getting the right result but If I am able to put max the solution will become dynamic which is required.

Thanks

SAK

sunny_talwar
MVP
MVP

Are you trying to get this?

Capture.PNG

Tab2:

LOAD * Inline [

Team1,Change1

A,10|20|30|40|50

];

FinalTable:

LOAD Distinct Team1

Resident Tab2;

FOR i = 1 to SubStringCount(FieldValue('Change1', 1), '|') + 1

  Left Join (FinalTable)

  LOAD Team1,

  SubField(Change1, '|', $(i)) as FieldName$(i)

  Resident Tab2;

NEXT

DROP Table Tab2;