There's moreā€¦

The variables can also be defined in external files, such as a text file, and then loaded into the application through the Data load editor.

In order to try this, complete the following steps:

  1. Download the Variables.xlsx file from the Packt Publishing website and set up a library connection to the file location called QlikSenseCookBook_SourceFiles (to resemble the FROM... code used in the following code).
  2. Copy and load the following code:
VariableDefinitions: 
LOAD 
    Variable, 
    Expression 
FROM [lib:// QlikSenseCookBook_SourceFiles/Variables.xlsx] 
(ooxml, embedded labels, table is Variables); 
 
Let vNumberOfRows = NoOfRows('VariableDefinitions'); 
For vI = 0 to (vNumberOfRows - 1) 
Let vVariable_Name = Peek('Variable',vI,'Expression'); 
Let [$(vVariable_Name)] = 
Peek('Expression',vI,'Expression'); Next; let vI = null(); Let vNumberOfRows = null(); let vVariable_Name = null();

If you now go back to the Variable list from the Edit sheet window, you will see a variable has been created for each row in the Excel file attached. The code below the FROM statement simply loops through each row of the Excel file, creating a new variable each time. The values in column A become the variable names, and the corresponding values in column B are used as the variable definitions.

This is the complete list of variables loaded:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset