Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

loading dynamic number of columns

Hello

I got a table to which I want to add 20 columns that take values 1 or 0

so suppose the load script is as such:

Load

Col1,

Col2

from....

How to accomplish something like

Load

Col1,

Col2,

For i=1 to 20

if (i%2=0 ,1,0) as Week & i

next

Please advise

I can walk on water when it freezes
2 Replies
IAMDV
Luminary Alumni
Luminary Alumni

Ali - Please can you explain the second bit again? Do you want to load dynamic number of columns or dynamic rows within those 20 columns?

Cheers,

DV

www.QlikShare.com

jeffmartins
Partner - Creator II
Partner - Creator II

Hi ali_hijazi,

You can include news columns dynamically using left join with a table.

Table:

LOAD * INLINE [

    Col1, Col2

    a, i

    b, h

    c, g

    d, f

    e, e

    f, d

    g, c

    g, b

    h, a

];

FOR i = 1 to 20

          vWeek = 'Week' & $(i);

          LEFT JOIN (Table)

          Load           Col1,

                               Col2,

                               if( mod($(i),2)=0,1,0) as $(vWeek)

          Resident Table;

NEXT

let vWeek =;

But why do you want to create so many columns in the script ?

Hope this helps you.

Regards