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: 
HartbargerL
Contributor II
Contributor II

Create Variable Names and Variable Values from Excel File

Hi, 

I am trying to create variables using the  values in an excel file:

Table:
LOAD
"Variable Name",
"Variable Value",
"Variable Definition"
FROM my_excel_file.xlsx;

let vName = peek([Variable Name], 2);

Trace test: $(vName);

My trace function is returning test: 

and the variable is not being created. 

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Good solution. But I'll point out that if there happened to be duplicate VariableNames, this would be a subtle bug,

Let vNoOfVariables = FieldValueCount ('VariableName') ;

Better to use 

Let vNoOfVariables = NoOfRows ('Application_Variables') ;

-Rob

View solution in original post

3 Replies
anat
Master
Master

Application_Variables:

LOAD VariableName,

     VariableDefinition

FROM

Test_27.xlsx

(ooxml, embedded labels, table is Test);

Let vNoOfVariables = FieldValueCount ('VariableName') ;

For v = 0 to $(vNoOfVariables)-1

 

Let vName = Peek('VariableName',$(v),'Application_Variables');

  Let $(vName) = Peek('VariableDefinition',$(v),'Application_Variables');

Next v

Drop Table Application_Variables;

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Good solution. But I'll point out that if there happened to be duplicate VariableNames, this would be a subtle bug,

Let vNoOfVariables = FieldValueCount ('VariableName') ;

Better to use 

Let vNoOfVariables = NoOfRows ('Application_Variables') ;

-Rob

HartbargerL
Contributor II
Contributor II
Author

Thanks! That worked for me!