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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Looping through columns in table load script

Hi People,

problem is simple:

I have table with columns names: @1,@2,@3....@10

I want to loop through these columns..

I wrote something like this:

for i= 1 to 10

Table_Name:

load distinct

@$(i) as Parent ( "i" here will be 1)

@$(i)+2 as Kid  ( "i" here supposed to be 3)

resident Table2;


next;

This script doesnt work for counting $(i) + 2 as result column name: @3.

How can it be done ?

Thank You in advance for your help,

Jacenk Antek

1 Solution

Accepted Solutions
maxgro
MVP
MVP

for i=1 to 10

  let j=$(i)+2;

  Table_Name:

  load distinct

       @$(i) as Parent,

       @$(j) as Kid

resident Table2;

next;

View solution in original post

11 Replies
luciancotea
Specialist
Specialist

@$(=i+2) as Kid

maxgro
MVP
MVP

for i=1 to 10

  let j=$(i)+2;

  Table_Name:

  load distinct

       @$(i) as Parent,

       @$(j) as Kid

resident Table2;

next;

jagan
Partner - Champion III
Partner - Champion III

Hi,

If it is static number of columns you can simply use below script without making the script more complex to understand

Table_Name:

load distinct

@1 as Parent,

@3 as Kid

resident Table2;


Concatenate(Table_Name)

oad distinct

@2 as Parent,

@4 as Kid

resident Table2;

'

'

''

'

'



PradeepReddy
Specialist II
Specialist II

if the table contains 10 columns (@1,@2,@3....@10), what is the need to loop the columns?

Mention whatever columns you want load from the resident table (Table2) explicitly..


Table:

Load @1 as Parent1,

         @2 as Kid

resident Table2;

Anonymous
Not applicable
Author

Hi,

thank you for your answer. Unfortunately this is not working:

error is :

So Kid (Subsetname) is not working - QV doesnt see it as @ and number.

Bez tytułu.png

Anonymous
Not applicable
Author

thanks! It is working !

Anonymous
Not applicable
Author

I wanted to learn somthening new but thx for answer.

Anonymous
Not applicable
Author

what if this table had 1000 columns?