Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
jessica_webb
Creator III
Creator III

Variable as part of filename

Hi,

This seems like it should be very straightforward, but... I still can't get it to work for me.

Basically, I have many data sources in my qvw, all with the same 'name' in different places. I also have to reload the data regularly and change the 'name'.

In the past, I have done a search replace, but I was hoping I could speed this up by using a variable.

So for example, my file path might be:

FROM

[..\..\SourceData\QV_Data\QVDs\Apple maps.qvd]

(qvd);

or

FROM

[..\..\SourceData\QV_Data\QVDs\england_spine Apple.qvd]

(qvd);

If I wanted to change 'Apple' to 'Orange', how would I do that?

So far I've got:

Set vName = Orange

And have changed the file path to:

FROM

[..\..\SourceData\QV_Data\QVDs\$(vName)map.qvd]

(qvd);

But when I run this I get:

FROM

[..\..\SourceData\QV_Data\QVDs\Orange

Directorymap.qvd]

(qvd)

Which obviously isn't recognised. How do I get the script to recognise the 'map.qvd' part of the file path?

Many thanks,

Jess

4 Replies
Anonymous
Not applicable

when I enter this script in a new qvw

Set vName = Orange;

Load *
FROM
[..\..\SourceData\QV_Data\QVDs\$(vName)map.qvd]
(
qvd);

and debug the script, I see correct value

Frank_Hartmann
Master II
Master II

try like this:

Set vName = 'Orange';

..

FROM

[..\..\SourceData\QV_Data\QVDs\$(vName) map.qvd] (qvd);

For me, it works like that way!

Hope this helps

puttemans
Specialist
Specialist

Hi Jess,

I have similar things in my script and they do work, so you are definitely on the right track.

e.g.  [$(vQVDTempPath)\Map_$(vCurrentProduct)_$(vCurrentYear$(vCurrentProduct))_$(vCurrentYearLoad)_$(vLoadAggregateAM)_Temp.qvd]

I would try

[..\..\SourceData\QV_Data\QVDs\$(vName) maps.qvd] (qvd); and

[..\..\SourceData\QV_Data\QVDs\england_spine $(vName).qvd] (qvd); (the path you give is not similar)

Or try when they are renamed like

[..\..\SourceData\QV_Data\QVDs\$(vName)_maps.qvd] (qvd); and

[..\..\SourceData\QV_Data\QVDs\england_spine_$(vName).qvd] (qvd); (so lose the blanks in the file name)

Regards,

Johan

jessica_webb
Creator III
Creator III
Author

Thank you all for your responses - it seems that it's something to do with me keeping 'Directory;' before my LOAD script.

I've always left it in as default (unless I'm joining tables), but I guess perhaps I shouldn't be!

Time to do some reading on the Directory function...

Thanks again,

Jess