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

Create a new table for each row of a table

Hello,

Consider this table:

Unbenannt.JPG

I would like to generate 3 new tables with the same fields ID's:

table1:

Unbenannt.JPG

table2:

Unbenannt.JPG

table3:

Unbenannt.JPG

can anyone help me ? thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Hm, you could separate your table into a table per record for example like this:

INPUT:

LOAD *, RowNo() as row INLINE [

items, stores, quantity

A, 1, 5

B, 1, 2

C, 10, 3

];

Let vMaxRow = Peek('row',-1,'INPUT');

For rowno = 1 to $(vMaxRow)

TABLE$(rowno):

NoConcatenate LOAD

items, stores, quantity

Resident INPUT where recno() = $(rowno);

next rowno

drop table INPUT;

But since you want to keep the field names the same (as I understood your original post), this will create a synthetic key and table that will link all tables. Still you can see (e.g. in table viewer, hovering with the mouse over the three created tables), that each table now holds only one record.

QV will link the fields automatically by equality of field names, and there is no way to stop QV from doing so.

But what are you trying to achieve? If you want to store the tables into separate files, fine, this should work.

But you probably want to do something with the tables in the front end, and I am unsure, what that could be.

There is probably a better solution for anything you want to do in the front end than separating the tables.

Regards,

Stefan

View solution in original post

4 Replies
swuehl
MVP
MVP

Please take a look at this discussion:

http://community.qlik.com/message/223188

Regards,

Stefan

Not applicable
Author

TY but I would like to do that in the script. Any idea ?    

swuehl
MVP
MVP

Hm, you could separate your table into a table per record for example like this:

INPUT:

LOAD *, RowNo() as row INLINE [

items, stores, quantity

A, 1, 5

B, 1, 2

C, 10, 3

];

Let vMaxRow = Peek('row',-1,'INPUT');

For rowno = 1 to $(vMaxRow)

TABLE$(rowno):

NoConcatenate LOAD

items, stores, quantity

Resident INPUT where recno() = $(rowno);

next rowno

drop table INPUT;

But since you want to keep the field names the same (as I understood your original post), this will create a synthetic key and table that will link all tables. Still you can see (e.g. in table viewer, hovering with the mouse over the three created tables), that each table now holds only one record.

QV will link the fields automatically by equality of field names, and there is no way to stop QV from doing so.

But what are you trying to achieve? If you want to store the tables into separate files, fine, this should work.

But you probably want to do something with the tables in the front end, and I am unsure, what that could be.

There is probably a better solution for anything you want to do in the front end than separating the tables.

Regards,

Stefan

Not applicable
Author

TY!