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

Dynamically create tables in script

Say I have a table with some pretty standard fields:

ID (prim key)

Name

Type_ID (for key)

Value

and I would like to create a different table within qlikview for each unique type_id. How would I do this? Obv I can always add a where clause in my SELECT statement and just assign different names to each field where applicable and name the tables, but the number of types may grow. Can this be done?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Not sure if I fully understood, but maybe like this?

Table:

LOAD * INLINE [

ID, Name, Type_ID, Value

1, One, Number, 10

2, Two, String, 20

3, Three, Number, 30

4, Four, String, 40

];

TypeTable:

LOAD Distinct Type_ID as TypeName resident Table;

For i = 0 to NoOfRows('TypeTable')-1 step 1

Let type = peek('TypeName', $(i), 'TypeTable');

[$(type)]:

NOCONCATENATE Load ID, Name as $(type)Name, Value as $(type)Value resident Table where Type_ID = '$(type)';

Next

Regards,

Stefan

View solution in original post

2 Replies
swuehl
MVP
MVP

Not sure if I fully understood, but maybe like this?

Table:

LOAD * INLINE [

ID, Name, Type_ID, Value

1, One, Number, 10

2, Two, String, 20

3, Three, Number, 30

4, Four, String, 40

];

TypeTable:

LOAD Distinct Type_ID as TypeName resident Table;

For i = 0 to NoOfRows('TypeTable')-1 step 1

Let type = peek('TypeName', $(i), 'TypeTable');

[$(type)]:

NOCONCATENATE Load ID, Name as $(type)Name, Value as $(type)Value resident Table where Type_ID = '$(type)';

Next

Regards,

Stefan

Not applicable
Author

Thanks I'll try this out. It looks like it might be what i'm looking for.