Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jessica_webb
Creator III
Creator III

Variable as string in script

I have a variable in my script as follows:

Set vAcadyear = 2016-17;

I then use this in several other places in my script (mostly in file names) which works just fine.

So

FROM

[$(vAcadyear)\Misc\Map.xls]

(biff, embedded labels, table is Points$);

Becomes

FROM

[2016-17\Misc\Map.xls]

(biff, embedded labels, table is Points$);

which is exactly what I want.

However, in another place in the LOAD statement I have:

LOAD

$(vAcadyear) as Year,

And that's not working as I want. In this case, it evaluates the variable, and gives me '1999' as 'Year' (i.e. 2016 minus 17!)

How do I get it to store this variable as a string, even though it "looks" like a calculation.

Thanks,
Jess

1 Solution

Accepted Solutions
tyagishaila
Specialist
Specialist

try it,

LOAD

'$(vAcadyear)' as Year,

View solution in original post

16 Replies
Anonymous
Not applicable

Hi!

Sorry, I dont understand:

LOAD

$(vAcadyear) as Year

Do you mean that you use the value 2016-17?

Is it possible to have the script or a sample app?

jessica_webb
Creator III
Creator III
Author

Yes, I would now expect the field 'year' to have the value '2016-17'

At the moment, it gives me the value '1999' which is wrong.

Anonymous
Not applicable

Hi Jessica,

  Could you check the source field format? I guess there is some mis match in the format.

-Jai

PrashantSangle

Hello,

try with double quotes

like

"$(vAcadyear)" as Year


Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jessica_webb
Creator III
Creator III
Author

Hi Jai,

I'm afraid I don't understand what you mean.

Anonymous
Not applicable

With load inline work fine:

Set vAcadyear = '2016-17';

T:
LOAD * INLINE [
F1, F2
A, $(vAcadyear)
B, $(vAcadyear)
]
;

Can you try to write let = '2016-17'?

Anonymous
Not applicable

Hi Jessica,

   Can you share the sample data, that look alike? (If Possible )

-Jai

jessica_webb
Creator III
Creator III
Author

Hi Prashant,

That gives me the following error:

Field not found - <2016-17>

Centre_data:

LOAD

"2016-17" as Year,

Anonymous
Not applicable

Jessica, try with let = '2016-17', it work.