Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
jagannalla
Partner - Specialist III
Partner - Specialist III

Display variable in table

Hi,

I have a variable in my qvw file. Now i want to display this variable in table.

- If is possible to store this variable in text file along with data.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Anytime you want to store anything in a file, you need to previously load it, unless you want to use some unnecessary (in my point of view) macro code.

VariableTable:

LOAD $(vVariable) AS Variable

AUTOGENERATE 1;

STORE VariableTable INTO File.txt (txt);

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

View solution in original post

17 Replies
Miguel_Angel_Baeyens

Hi,

Anytime you want to store anything in a file, you need to previously load it, unless you want to use some unnecessary (in my point of view) macro code.

VariableTable:

LOAD $(vVariable) AS Variable

AUTOGENERATE 1;

STORE VariableTable INTO File.txt (txt);

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    You can display variable in Straight Table. Just place "=Varibale_Name" in Expression if it contains value. If it is an expression then use "=$(Variable_Name).

    For second Question - Yes you can store varibales in text file and then use them in Qlikview.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Miguel,

what you said correct but the think is when i'm using this text file in another qvw file using include statement (i.e., $(Include=d:\examples\file.txt);). Shows the error message while loading qvw file.

Capture.PNG

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Its because you have not declared the variable properly in text file.

    Make sure your text file have variable declaration like below.

    Set vVariable1 = 'ABC';

    Set vVariable2 = 'PQR';

    ............... And so on,

     Hope this will help you.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Kaushik,

I created the vVariable globally and now i'm using this variable in edit script. The think is i want to store this variable in text file and i want to use the data of particular variable.

As per miguel give code its creating a variable along with data in the text file. How to set variable property in text file as per code given my miguel.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Can you please explain what are you trying to achieve, this will help us to understand your problem in detail.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Miguel_Angel_Baeyens

Hi,

Are you using "File.txt" (the file where you previously stored the table with the variable) as the include file? In that case, you will need to LOAD the file instead of use it in the include, since it's not properly formatted to be used as a piece of script code.

In other words, you cannot save a txt file with a variable as a field (as in my example above) and then use it in the include variable. The include variable inserts the text in the file specified in the script, and so this text must be a valid script code.

Here's my guess on what you want to get

// Load variable saved in previous STORE statement or in a different document

Variable:

LOAD Variable

FROM

C:\File.txt

(txt, utf8, embedded labels, delimiter is '\t', msq);

LET vDestinationVariable = FieldValue('Variable', 1);

DROP TABLE Variable; // Cleanup

Now, in the second file, vDestinationVariable has the same value it has in the file you have stored it.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Thanks a lot miguel I need some more help from you.

- If the variable contains the data in string format i mean  i.e., vVariable=A or vVariable=A,B,C,D

It showing an error.

What i'm trying to achive is i had taken a list box and based on my selections i'm storing particular selections into variable.

I'll attach my file for your reference to understand what i'm doing.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    All you have to do is place $(Variable) in single quote ie.

    load

    '$(Variable)' as Variable

    ............

    Go through the attahcment.

    Hope this will help you

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!