Qlik Community

QlikView Documents

Documents for QlikView related information.

Export Variables.zip

Valued Contributor

Export Variables.zip

Many a times we may want to have same variables in different Qlikview document. So, we can put all those variables in a spreadsheet can bring them in Qlikview document using a simple piece of script.

Similarly, sometimes we may want to have variables from one Qlikview document in other. Since there is no direct way to achieve this, there is a workaround. We can export the variables from the source Qlikview document to spreadsheet and then they can be brought into destination Qlikview document as mentioned above.

I have used 4 files to demonstrate this. There are two Qlikview documents and two spreadsheets.

Variables (Spreadsheet) - This file describes how should we store Variable information to bring back in Qlikview. There would be two columns First column is the name of variable and the second one is the valid Qlikview expression/Function.


Importing Variables (QV) - This file contains the script to bring variable name and their corresponding expression from spreadsheet and then creating the required variables.


Now, It's time to know how variables can be exported to spreadsheet, so that later they can be bring into other Qlikview document. Before we talk about it, Let's discuss why we are exporting variables from one document to spreadsheet and then using that spreadsheet to create variables in new Qlikview document, why we don't use the same spreadsheet which we used Initially to create variables.

The answer to this question is, of course we can use old spreadsheet again. We will get those variables created but if we want to have the values of those variable from Source Qlikview document we will not get those.

For ex: we will not get the same value for variables in new document,


So, If we want not only want to use same variable but also wish to use same value inside those variables then we have to use this export-import method.

Exporting Variables (QV) - This document will export the variables and the values stored in them to spreadsheet. For this to achieve it contains one Straight Chart with one dimension and expression. And a macro which exports the variable details from chart to spreadsheet(Export_Var).

Importing Variables (QV) - Now when we reload this Qlikview document, same variable will be created here but they will retain the values which they had in Exporting Variables Qlikview document.

Labels (1)
Valued Contributor

Excellent! Very useful contribution!

Thanks a lot!

Contributor III

This is brilliant!!

MVP & Luminary
MVP & Luminary

Good post. It's generally a best practice to maintain variables in an external file and load them from there as you have demonstrated.  While not common, it is possible to directly load variables from one qvw to another using this script:





// below is QVW we want to copy variables from

FROM [..\..\data\StudentFile.qvw]

(XmlSimple, Table is [DocumentSummary/VariableDescription])

Where IsConfig = 'false' and IsReserved = 'false'  // Exclude system vars

// Any addtional filtering here


FOR idx=0 to NoOfRows('VariableDescription')-1

    LET vVarname = Peek('Name',$(idx),'VariableDescription');

    LET [$(vVarname)] = Peek('RawValue',$(idx),'VariableDescription');

NEXT idx

SET idx=;

SET vVarname=;

DROP Table VariableDescription;


PS. I think there is an error in your posted code images above. I don't think you want a '=' before the peek() in the image above. It's not in your downloadable sample.

Contributor III

Hi Rob,

Thanks for your comment. Your solutions are always awesome and inspires me a lot.




Hi guys,

is there a way to export variables from the application itself during reload? We would like to use Git as our source control solution for development - but as you probably already know - variable definitions are not saved in the prj folder. My aim is, to export the applications variables at the end of the reload into a txt file residing in the prj folder. After that we will be able to fully recreate the app including the variables. Is there a way to do that? Any advice is appreciated!



MVP & Luminary
MVP & Luminary

In  my experience the best solution is to establish/maintain all variables from script, then you don't have to worry about exporting anything. 

If you need to export the current variables you can use a bit of macro code to enumerate the variables and load them to a table and then store that table as a QVD or CSV. See Kamal's sample file for an example of the macro code.


Thanks Rob,

yeah, that would have been the optimal solution but the application I have to work with was created so, that it uses a gazillion variables, many with getselectionfield function, which does not operate in the script (if I am correct). What I could manage to do that with your help though, is to use your code (importing variables from another QVW) and by the 'from' clause writing the URL of the application itself. This way I was able to store the applications variables.

Thanks again,


New Contributor III

If I have a field name and I would like to use it in further operation in the script, how can I do that?




Column1 & '|' & Column2 as NewFieldName,


From ............

For better detailed example please check the link and let me know what you think I should do:

Edit Some data according to some criterio from the script

Version history
Revision #:
1 of 1
Last update:
‎2017-05-29 09:16 AM
Updated by: