Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

set variable from text file

Hi Everyone,

I am wating to create a set statement that pulls information from an external text file in the load script.

So rather than:

Set x='May, June, July'

I want the 'May, June, July' to come from a text file stored locally.

Is this possible?

Thanks

Gareth

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Gareth,

I'd do a concatenated load of all possible values in your text file (one value per file in the text file), using the code as

ValuesTemp:

LOAD Chr(39) & Concat(Value, Chr(39 & Chr(44) & Chr(39)) & Chr(39) AS AllValues

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

LET vVariable = FieldValue('AllValues', 1);

DROP TABLE ValuesTemp;

The file is called file.txt and it has only one field named "Value". It takes more work than hardcoding the values but it may worth doing this to have a greater control in an external file.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

View solution in original post

2 Replies
Miguel_Angel_Baeyens

Hello Gareth,

I'd do a concatenated load of all possible values in your text file (one value per file in the text file), using the code as

ValuesTemp:

LOAD Chr(39) & Concat(Value, Chr(39 & Chr(44) & Chr(39)) & Chr(39) AS AllValues

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

LET vVariable = FieldValue('AllValues', 1);

DROP TABLE ValuesTemp;

The file is called file.txt and it has only one field named "Value". It takes more work than hardcoding the values but it may worth doing this to have a greater control in an external file.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

SunilChauhan
Champion II
Champion II

hello

please find the attached .use text file instead of excel.

change the code accodingly will give u desired result.

Sunil Chauhan