Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jayabedin
Contributor III
Contributor III

LET statement to extract text variable

Hi,

I am using LET statement to store some text values in script. I have used the syntax

LET vField1 = $(Field1);

when displaying values using

=$(vField1)  getting a  minus(-) sign.

Your early response will be highly appreciated.

Regards

Jay.

1 Solution

Accepted Solutions
uacg0009
Partner - Specialist
Partner - Specialist

HI Jaynal,

I think because the Field1 is a field, so it will have more than 1 value in it, so the variable can not show all the values using that method.

I think you need to use concat funciton like:

set vtest = =Concat(DISTINCT Field1,',');

Thanks.

Aiolos

View solution in original post

10 Replies
vishsaggi
Champion III
Champion III

What is this Field1? IS this a variable or a field from a table?

To store text values i Use set rather than Let.

Can you share some sample values?

Oh hold on does the Field1 has multiple values if yes you might want to use Concat() function to get multiple values.

sushil353
Master II
Master II

Hi Jaynal,

is the Field1 is field of a table or a variable earlier calculated in the script ?

if Field1 is a field of a table then u can use following code

Temp:

Load Field1 from table X;

LET vField1  =  peek('Field1',0,'Temp');

HTH

Sushil

jayabedin
Contributor III
Contributor III
Author

Hi Sushil,

Field1 is a field in a table with multiple values.

If I understood you correctly the syntax peek will extract value 0 and Temp from Field1.

Thank you very much. i will give it a go.

jayabedin
Contributor III
Contributor III
Author

Hi Vishwarath,

Thank you very much for the quick response.

Field1 is a field in a table.

what would the syntax for SET statement?

SET vPriority_Code1 = $('PriorityMap.Priority_Code');

Is the syntax correct?

jayabedin
Contributor III
Contributor III
Author

Hi Sushil,

Looks like there is issue with my syntax below.

LET vPriority_Code2 = peek('PrioirityMap.Priority_Code','P1','P2');

sushil353
Master II
Master II

Hi Jaynal,

what is P1 and P2 ?

Peek function will fetch a field records from a table based on the index values of the record.

General syntax is Peek('FieldName',indexvalue,'TableName')

HTH

Sushil

sushil353
Master II
Master II

Index value should be a number without quote sign

vishsaggi
Champion III
Champion III

Are you looking for Multiple values or one single value from your text field?

When you say $(PriorityMap.Priority_Code) is this a variable or Field name from your Load script.

If PriorityMap.Priority_Code is your Field name you should try

SET vPriority_Code = 'PriorityMap.Priority_Code';

Then use like in your textbox

= $(vPriority_Code)

If you have multiple values you might want to add a temp table like below:

Temp:

LOAD Concat(DISTINCT PriorityMap.Priority_Code, '|') AS StringValue

Resident YoursourceTablename;

SET vString = 'PriorityMap.Priority_Code';

SET vPriority_Code = 'StringValue';

= $(vPriority_Code)

uacg0009
Partner - Specialist
Partner - Specialist

HI Jaynal,

I think because the Field1 is a field, so it will have more than 1 value in it, so the variable can not show all the values using that method.

I think you need to use concat funciton like:

set vtest = =Concat(DISTINCT Field1,',');

Thanks.

Aiolos