3 Replies Latest reply: Jun 6, 2017 3:40 AM by Bill Markham RSS

    Using a variable in Data Connection

    Amirali Vastani

      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

        • Re: Using a variable in Data Connection
          Bill Markham

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




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

            • Re: Using a variable in Data Connection
              ar eiuiew

              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')



              Load '$(vFile)' as FName,

              FileTime( '$(vFile)' ) as FileTime

              autogenerate 1;

              next vFile


              first 1




              1 as dummy

              Resident Files

              Order By FileTime DESC;

              drop table Files;


                        Let vMaxFile=FName;



              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
                  Bill Markham

                  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) ;