Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

avastani
Contributor II

Using a variable in Data Connection

is it not possible to reference a variable in the data connection in the lib:// definition?

would like to do

http://URL/$(variable) in my connection but get an Internal Error

3 Replies

Re: Using a variable in Data Connection

Maybe create a lib connection for http://URL called say YourURL and then use it the script as :

     [lib://YourURL]/$(variable)

Thus adding your variable to the end of the lib connection within the script.

arixooo123
Contributor

Re: Using a variable in Data Connection

Hi Bill,

I do have the same issue here, I ran below script but had an  issue.. I'll be grateful if you check and let me know

for each vFile in FileList('lib://QlikData/*.qvd')

        

Files:

Load '$(vFile)' as FName,

FileTime( '$(vFile)' ) as FileTime

autogenerate 1;

next vFile

LatestFile:

first 1

Load

FName,

FileTime,

1 as dummy

Resident Files

Order By FileTime DESC;

drop table Files;

          Let vMaxFile=FName;

   

Consignments:   

Load * from [lib://QlikData/'$(vMaxFile)'](qvd);

It doesn't load any file, the error  is :

The following error occurred:

Cannot open file: 'lib://QlikData/'''

Re: Using a variable in Data Connection

I suspect the issue with line :

    Let vMaxFile=FName;

You probably need to use the peek() function, maybe something like :

    let vMaxFile= peek('FName',0,'LatestFile');

Also you could use Trace to check what is actually stored in the variable :

    Trace vMaxFile: $(vMaxFile) ;

Community Browser