Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

robert_dolezych
New 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

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

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,

6 Replies

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

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

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

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;

robert_dolezych
New Contributor II

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

Thank you Michele

Regards

Robert

robert_dolezych
New Contributor II

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

Thank you Peter

it was realy helpful

regards

Robert

prma7799
Honored Contributor III

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

Hi Robert ,

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

Thanks

micheledenardi
Valued Contributor

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

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

Community Browser