Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
mhmmd_srf
Creator II
Creator II

Define Variable Dynamically

Hi All,

I have a requirement like :

I will have an excel file. Which will have Key and Values.

From that excel I want to define the Variable.

As an example:

set vDBSchema1= should be AHPDW.AHPMart.

I am attaching the App. Could you please check and let me know the way out.

Thanks,

Sarif

2 Replies
trdandamudi
Master II
Master II

If you have values in excel and you want to load them into Qlikview and create dynamic variables then follow the below code as example. I created all the variables in excel and loaded into qlikview to create dynamic variables. Hope this helps...

Variables_tmp:
Load
Name,
Expression,
Comment
FROM
   <------------------ Make sure you point this to your path
(
ooxml, embedded labels, table is Sheet1);

// Create Variables
Let vNoOfVariables = FieldValueCount('Name');
For i = 0 to $(vNoOfVariables) - 1
Let vName = Peek('Name',i,'Variables_tmp');
Let vComment = Peek('Comment',i,'Variables_tmp');
Let $(vName) = Peek('Expression',i,'Variables_tmp') & CHR(10) & '// $(vComment)';
Next i
Drop Table Variables_tmp;

// Drop below variables and also go to Settings--->Variables Overview and then delete vName,vComment,vNoOfVariables and i varibales manually. 

Set vName=;
Set vComment=;
Set vNoOfVariables=;
Set i=;

Create below excel file

Variables_List.xlsx   <------ This is Excel file

Name                      Expression                              Comment

Revenue                Sum(Orders*Price)                   Total Revenue

Anonymous
Not applicable

Try something like

temp:

Load Value as Requiredvalue from AHPConfig where Key = 'vDBSchema';

LET vDBSchema1 = Peek('Requiredvalue');

drop table temp;