Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

Copy variable

Hello gurus

I have created a new document with a Binary load from an existing one.

However, variables are not being copied/transferred with the Binary load.

Is there a way to copy all variables (i have many of them) from the existing document to the new?

 

Thanks

2 Solutions

Accepted Solutions
Highlighted
MVP
MVP

Re: Copy variable

This is how you can retrieve the variable info:

 

VARIABLE:
LOAD 
    Name,
    IsConfig,
    IsReserved,
    RawValue
FROM 
  [C:\Program Files\QlikView\Examples\Documents\Getting Started.qvw] 
  (XmlSimple, Table is [DocumentSummary/VariableDescription]);

View solution in original post

Highlighted
MVP & Luminary
MVP & Luminary

Re: Copy variable

This blog post contains the code to both load and recreate the variables: https://qlikviewcookbook.com/2018/06/loading-variables-from-another-qvw/

View solution in original post

11 Replies
Highlighted
MVP
MVP

Re: Copy variable

Yes the variables are not part of the data model of QlikView or Qlik Sense.

And yes there is a way of getting hold of the variables by reading them from the QVW-file. The QVW-file has an XML-section where the variables are accessible. 

You will have to read the QVW-file from a load script with a LOAD statement using XML as the file format. Then you will get all the variables into a table. The table can be parsed with a simple FOR loop afterwards to recreate each and every variable.

 

Highlighted
MVP
MVP

Re: Copy variable

Another approach is to make a QlikView macro with either VBScript or JScript (JavaScript). There is an API that let you manipulate and read anything in a QlikView document - variables are also fully accessible this way.

 

Furthermore there are applications being made as "open-source" to do the job:

 

ImportExportVariables.png

Highlighted
Specialist
Specialist

Re: Copy variable

Thanks.

A little more help... Using QlikView not QlikSense

Where can the XML section be found?

Highlighted
MVP
MVP

Re: Copy variable

This is how you can retrieve the variable info:

 

VARIABLE:
LOAD 
    Name,
    IsConfig,
    IsReserved,
    RawValue
FROM 
  [C:\Program Files\QlikView\Examples\Documents\Getting Started.qvw] 
  (XmlSimple, Table is [DocumentSummary/VariableDescription]);

View solution in original post

Highlighted
Specialist
Specialist

Re: Copy variable

You are the BEST!!!

Thanks for your help

Highlighted
MVP & Luminary
MVP & Luminary

Re: Copy variable

This blog post contains the code to both load and recreate the variables: https://qlikviewcookbook.com/2018/06/loading-variables-from-another-qvw/

View solution in original post

Highlighted
Specialist
Specialist

Re: Copy variable

Thank you Rob.

You always come through!

What would we do without you?  😊

Highlighted
Contributor II
Contributor II

Re: Copy variable

That script helps to get variables in application but my question is how we can create variable in application . Any suggestions?

Highlighted
Contributor II
Contributor II

Re: Copy variable

I am using that script i have imported 100 variables now i want a script using that i can create all variable in my application instead of manual work. is it possible.