Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

custom default (aka environment) variables ?

Hi,

Is it possible to have custom default (aka environment) variables additionally in desktop QV? Meaning that these variables will be avilable by default in all documents like the number interpretation variables. Can I add my custom variables into the set of the "number interpretation" variables, so it would be inserted into load scripts by default?


I known that there is API function to import variables from a file. Bu I couldn't find how to have "default" macros that would be run at every document load/creation...It is diffrent but related problem, to have default VBscript function library....That apperently is the way to go. For each new QV file , manually add VBscript code to include extrenal VBscript file and ExecuteGlobal its content. It will provide custom VBS functions and variables(?)

Any suggestions/comments would be appreciated

Thanks

Vlad





Labels (1)
1 Solution

Accepted Solutions
marcel_olmo
Partner Ambassador
Partner Ambassador

OK Vladimir, I'll show you how it works.

I have an excel sheet that has variables like this

variable, valor

var1 1

var2 0

var3 1

...

and inside the script of the QV document I do something like this :

(What I do is loading the excel in a table called "VariablesConfig" and then I do a peek() to get the name of the variable and their value and I put it into variables of the QV document).

VariablesConfig :

LOAD variable,
valor

FROM
[variablesConfig.xls]
(biff, embedded labels, table is Hoja1$);

Let vNroRegistros = NoOfRows('VariablesConfig');
For vI = 0 to (vNroRegistros - 1)
Let vNombre_Variable = Peek('variable',vI,'VariablesConfig');
Let [$(vNombre_Variable)] = Peek('valor',vI,'VariablesConfig');
Next

Hope it helps!!

Cheers!

View solution in original post

3 Replies
marcel_olmo
Partner Ambassador
Partner Ambassador

Hey recently I've done something similar. I load an external excel full with variables and when you load them into a QV file, they turn into document variables.

Very useful to show/ hide stuff, or maybe customize the document. I'm currently using it to put financial variables of my customers.

Here's the link :

http://community.qlik.com/media/p/139678.aspx

I hope it helps!!

Anonymous
Not applicable
Author

Marcel,

I can't open your document with my Persinal Edition. But I guess that you have some VBscrupt stuff that go though the loaded table and put field values into new variables via CreateVarable->SetContent API methods. Right? It is essentially I meant mentioning VBscript way. I couldn't find ImportVars that imported variables from text file in the QV10 API. But obviosly it is possible to replace it with VBscrip using CreateVarable->SetContent

Vlad

marcel_olmo
Partner Ambassador
Partner Ambassador

OK Vladimir, I'll show you how it works.

I have an excel sheet that has variables like this

variable, valor

var1 1

var2 0

var3 1

...

and inside the script of the QV document I do something like this :

(What I do is loading the excel in a table called "VariablesConfig" and then I do a peek() to get the name of the variable and their value and I put it into variables of the QV document).

VariablesConfig :

LOAD variable,
valor

FROM
[variablesConfig.xls]
(biff, embedded labels, table is Hoja1$);

Let vNroRegistros = NoOfRows('VariablesConfig');
For vI = 0 to (vNroRegistros - 1)
Let vNombre_Variable = Peek('variable',vI,'VariablesConfig');
Let [$(vNombre_Variable)] = Peek('valor',vI,'VariablesConfig');
Next

Hope it helps!!

Cheers!