Qlik Community

Ask a Question

Documents

QlikView documentation and resources.

Announcements
Live chat with experts, bring your API Integration questions. June 15th, 10 AM ET. REGISTER TODAY

Easily managing global variables externally

RonaldDoes
Partner
Partner

Easily managing global variables externally

A really simple script I must_include at the beginning of all my scripts to load global variables, managed in a seperate place (an Excel file in the example below, could of course be just as well SQL.

Any comments of course greatly appreciated.

// ---------------------------------------------------------------------------

// Script to load global variables from Excel file and store into variables

// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------

// Load global variables from Excel file into a table

// ---------------------------------------------------------------------------

Variables:

LOAD Name,

     Value

FROM

[QlikView variables.xlsx]

(ooxml, embedded labels, header is 1 lines, table is variables);

// ---------------------------------------------------------------------------

// Storing the global variables into variables

// ---------------------------------------------------------------------------

Let RowCount = NumMax(NoOfRows('Variables'),0)-1;

For i=0 to '$(RowCount)'

  Let TempVarName = peek('Name',$(i),'Variables');

  Let TempVarValue = peek('Value',$(i),'Variables');

  Let $(TempVarName) = '$(TempVarValue)';

Next

// -------------------------------------------------------------------------------------------

// A bit of housecleaning, we won't be needing the temporary variables as well as the table

// -------------------------------------------------------------------------------------------

Let TempVarName = null();

Let TempVarValue = null();

Let RowCount = null();

DROP TABLE Variables;

Naamloos.png

Tags (1)
Attachments
Comments
santiago_respane
Specialist
Specialist

Very useful tip!

Thanks a lot for sharing.

Regards,

0 Likes
manojkulkarni
Partner
Partner

Thanks for Sharing

0 Likes
vsr_shimla
Contributor II
Contributor II

Great work,

Thanx for sharing

0 Likes
dafnis14
Specialist
Specialist

Great Help!

Thanks for sharing!

0 Likes
markmccoid
Partner
Partner
I also think this is a great idea, but found that the Excel spreadsheet became difficult to manage as the number of variables grew. I have created an application to help ease this pain if anyone is interested in giving it a try: Here is a quick write up: https://community.qlik.com/t5/QlikView-Documents/Qlikview-Variable-and-Group-Manager-Application/ta-... Or you can download from github: https://github.com/analytixncs/qlikview-utility/releases/tag/0.1.0-alpha
0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2017-05-30 03:37 AM
Updated by: