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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
atsushi_saijo
Creator II
Creator II

In a loop (For....) create a variable dynamically

I would appreciate for any comment/solution on such case:

Given such table: Master

Department
Equity
Bond-Corporate
Guild
Commodity
.....(and so on)

I would like to create such loop with a=, b= , c=.....

Let vMax=NoOfRows('Master')

For i=0 to vMax-1

Let a = Peek('Department',$(i),'Master');

Next

Is there any way that I can dynamically generate the variable so that when loop goes on, I get

a='Equity'

b='Bond-Corporate'

c='Guild'

d='Commodity'

......

and so on.

These values are used in the front-end purpose. (mainly text boxes etc.)

I would appreciate for any feedbacks.

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

May be like this

Master:

LOAD * INLINE [

    Department

    Guild

    Equity

    Commodity

    Bond-Corporate

];

Let   a=65;

Let vMax=NoOfRows('Master');

For i=0 to vMax

  Let A=Chr($(a));

  LET $(A) = Peek('Department',$(i)-1,'Master');

  a=a+1;

Next

View solution in original post

4 Replies
settu_periasamy
Master III
Master III

May be like this

Master:

LOAD * INLINE [

    Department

    Guild

    Equity

    Commodity

    Bond-Corporate

];

Let   a=65;

Let vMax=NoOfRows('Master');

For i=0 to vMax

  Let A=Chr($(a));

  LET $(A) = Peek('Department',$(i)-1,'Master');

  a=a+1;

Next

maxgro
MVP
MVP

Master: 

LOAD * INLINE [ 

  Value

    Department 

    Guild 

    Equity 

    Commodity 

    Bond-Corporate 

]; 

For i = 0 to NoOfRows('Master')-1

    LET vName = chr(ord('a') + $(i));

    LET $(vName) = Peek('Value', i, 'Master');

Next i

1.png

atsushi_saijo
Creator II
Creator II
Author

Sorry kept you waiting  for my reply. Yes this works, and since you are the first person, I award you.

atsushi_saijo
Creator II
Creator II
Author

Thank  you for your answer, and sorry for the late reply. Yes this works!