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

How to selectively read value as variable or as a literal

 

I am trying to have some values read as literals while others should be replace by the variable value.

 

Example Input file:

 

So when I do this the first four ID’s come as I want which is literal. However I want the fifth one to show as ‘111’,’222’,’333’

 

 

 

Variable Output I Get

 

 

 

v_ID1 = ‘111’

 

v_ID2 = ‘222’

 

v_ID3= ‘333’

 

v_ID4= ‘444’

 

v_ID5= $(v_ID1),$(v_ID2),$(v_ID3)

 

My script is like this:

 

 

Test:
LOAD

Type,
Variable
,
$(vVariableValue) 
//NOTE I do have this variabalized but for the input file examples sake I kept just one example to keep it simpler

FROM

'..\includes\File1.xlsx'
(
ooxml, embedded labels, table is Sheet1) ;


LET vNumberofRows = NoOfRows
('Test');
For vI = 0 to (vNumberofRows
- 1);

LET vVariable= Peek('Variable',vI
,'Test');
LET vValue= Peek ('$(vVariableValue)',vI
,'Test');
LET [$(vVariable)] = Peek ('$(vVariableValue)', vI
, 'Test') ;

Next;

Do I Need to do some sort of IF logic inside of the loop to treat these differently?

I just can’t seem to get the syntax to work

Also note, I am trying to do this without minimal changing of the source excel file format.

 

0 Replies