Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
robert_dolezych
Contributor II
Contributor II

How to create a script variable from table values to use it with the "from" command?

  Hi Community

I have some file names in my table. I would like to use them as variables within the "from" command?
Is there any possibility to create such variables?

Thank you for your help

Robert

 

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Yes, for example like this. Imagine that we have a table called Filenames with a single field called FName. Every row contains a different QVD file name.

:

FOR i = 0 TO NoOfRows('Filenames')-1

  LET vFName = peek('FName', i);

  Table:

  LOAD * FROM [$(vFName)] (qvd);

NEXT

:

There are many more complex examples available in the community,

View solution in original post

6 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Yes, for example like this. Imagine that we have a table called Filenames with a single field called FName. Every row contains a different QVD file name.

:

FOR i = 0 TO NoOfRows('Filenames')-1

  LET vFName = peek('FName', i);

  Table:

  LOAD * FROM [$(vFName)] (qvd);

NEXT

:

There are many more complex examples available in the community,

micheledenardi
Specialist II
Specialist II

You have first to read the table as is than use peek function inside a for statement to reach the goal.

Something like:

OriginalTab:

Load

    Field1,

    Field2,

    ...

From db.table1;

For n=0 to NoOfRow(OriginalTab)

    Let vSource = peek('Field1',n,'OriginalTab');

    if n=0 then

          NewTable:

          NoConcatenate

          Load

               *

          From $(vSource);

     Else

          Concatenate(NewTable)

         Load

               *

         From $(vSource);

     End if

 

Next

drop table OriginalTab;

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
robert_dolezych
Contributor II
Contributor II
Author

Thank you Michele

Regards

Robert

robert_dolezych
Contributor II
Contributor II
Author

Thank you Peter

it was realy helpful

regards

Robert

prma7799
Master III
Master III

Hi Robert ,

If you get right answer then please close this thread to mark right answer.

Thanks

micheledenardi
Specialist II
Specialist II

Please,

when applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.



Regards

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.