Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
jessica_webb
Contributor 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

Tags (1)
4 Replies
Partner
Partner

Re: Variable as part of filename

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
Honored Contributor II

Re: Variable as part of filename

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

Highlighted
puttemans
Valued Contributor

Re: Variable as part of filename

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
Contributor III

Re: Variable as part of filename

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