Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
MEBG93
Creator
Creator

Can't use a variable when creating it in Data Load Editor

Hello experts!

I'm trying to create a variable in the data load editor using 'let', but after I load the data I can't find it in the Variable Panel. The objective of this variable is to load a long and repetitive If statement string and the field from the table is just one cell value.

I'm loading the table and then creating the variable:

 

table:

load

Expression1

from Expressions.xlsx;

 

let vExpressionSales = fieldvalue('Expression1', 1);

 

Thanks in advance

1 Solution

Accepted Solutions
RsQK
Creator II
Creator II

Hi, I would solve this a bit differently. So, I imagine your excel looks something like this:

RsQK_0-1664818176003.png

and with this script:

Expressions:
LOAD
    "Variable Name"	as var,
    Expression
FROM [lib://DATA/Expressions.xlsx]
(ooxml, embedded labels, table is Sheet1);

FOR i = 0 TO NOOFROWS('Expressions')

LET v_var = PEEK('var',$(i),'Expressions');

LET [$(v_var)] = PEEK('Expression',$(i),'Expressions');

NEXT i;

DROP TABLE Expressions;

you can get script generated variable list, that looks like this:

RsQK_1-1664818265622.png

 

View solution in original post

3 Replies
Frank_S
Support
Support

Hi MEBG93
Please check this solution and let us know if this solves it for you.

 

https://community.qlik.com/t5/New-to-Qlik-Sense/How-to-use-variables-in-load-scripts/td-p/873663

 

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
RsQK
Creator II
Creator II

Hi, I would solve this a bit differently. So, I imagine your excel looks something like this:

RsQK_0-1664818176003.png

and with this script:

Expressions:
LOAD
    "Variable Name"	as var,
    Expression
FROM [lib://DATA/Expressions.xlsx]
(ooxml, embedded labels, table is Sheet1);

FOR i = 0 TO NOOFROWS('Expressions')

LET v_var = PEEK('var',$(i),'Expressions');

LET [$(v_var)] = PEEK('Expression',$(i),'Expressions');

NEXT i;

DROP TABLE Expressions;

you can get script generated variable list, that looks like this:

RsQK_1-1664818265622.png

 

MEBG93
Creator
Creator
Author

Thanks!!