Qlik Community

QlikView Documents

Documents for QlikView related information.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER

Easily managing global variables externally

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)
Labels (3)
Attachments
Comments
Specialist
Specialist

Very useful tip!

Thanks a lot for sharing.

Regards,

0 Likes
Partner
Partner

Thanks for Sharing

0 Likes
Contributor II
Contributor II

Great work,

Thanx for sharing

0 Likes
Specialist
Specialist

Great Help!

Thanks for sharing!

0 Likes
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: