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

Dynamic Variable creation

Hi

I have a requirement where I should create variables dynamically.

The variable names along with its value will be entered in a Excel sheet. Have attached the sample Excel file for reference.

There will be two columns in the Excel file. First column will have the variable name and second column will have the value to be assigned to the variable.

In qlikview i should create the variables and assign them the values entered in the Excel.

Note: The number of variables may change. Number of variables may increase each day.

Is there a way to do so? Please help me on this.

Thanks in advance

7 Replies
svenkita
Creator II
Creator II

you will have to do it via macros

Check this link out

Importing and exporting variables - The Qlik Fix! The Qlik Fix!

tresesco
MVP
MVP

VarTable:
Load * Inline [
VariableName,Value
vVariable1,1
vVariable2,25
vVariable4,74
vVariable7,4
vVariable8,55
];

For i=1 to NoOfRows('VarTable')
      let vName=Peek('VariableName',-$(i));
      Let '$(vName)'=Peek('Value', -$(i));
Next i


gautik92
Specialist III
Specialist III

Set vVariable1=1

Set vVariable2=25

and so on

svenkita
Creator II
Creator II

this I found in qlikfix and is 100% match with what you are looking for

The import and export of variables are done via macors

attached is the sample copy both the file to the same folder and try it out

Anonymous
Not applicable
Author

Thanks everyone for the help

ankitbisht01
Creator
Creator

Nice solution , also worked like this

For i=0 to NoOfRows('VarTable')

      let vName=Peek('VariableName',$(i));

      Let '$(vName)'=Peek('Value', $(i));

Next i


Thank You.

barryharmsen
Luminary Alumni
Luminary Alumni

Very nice that people are looking at my blog for solutions In this case though, I'd like to suggest another post from my blog which does exactly what you ask:

Storing variables outside of QlikView - The Qlik Fix! The Qlik Fix!

Kind regards,

Barry