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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Looping through a table to convert a list field into a new table

Hi all,

I am loading a table into QV that contains a 'Program' field which has multiple values in it of the form:

"P00249; P00282; P00084"

I would like to be able to take my table, loaded as 'RAGInfo', and loop through each project, going through that field, breaking it down and storing into a new table.

So for the above example,

I would have 3 rows for the one project:

Project Program
D01234 P00249
D01234 P00282
D01234 P00084

Can anybody show me how I can code this action.
I'm guessing some kind of FOR loop

Thanks in advance,

Matt

1 Solution

Accepted Solutions
Not applicable
Author

Matt,

You can use a 'for each / next' loop - see 'help'

Another method depending on the data structure is simply to use subfield to break the data up during a load - cut and paste the following into a test document to see what I mean:

test1:
LOAD * INLINE [
F1
s1;s2;s3;s4;s5
];

load subfield(F1, ';') as F2
resident test1

Hope this helps.

Gordon

View solution in original post

4 Replies
Not applicable
Author

Matt,

You can use a 'for each / next' loop - see 'help'

Another method depending on the data structure is simply to use subfield to break the data up during a load - cut and paste the following into a test document to see what I mean:

test1:
LOAD * INLINE [
F1
s1;s2;s3;s4;s5
];

load subfield(F1, ';') as F2
resident test1

Hope this helps.

Gordon

Not applicable
Author

Thanks Gordon, thats great.

I have never come across the subfield function before, but it worked perfectly.

Many thanks for your suggestion.

Matt

Not applicable
Author

Hi Gordon,

I have the exact same scenario, but in reverse. He wanted to extract 3 rows of data from the 1 row. I want to combine 3 rows of data into 1 row.

Any ideas?

Thanks,

-Kevin

Not applicable
Author

Simply concatenate the rows as :