Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating QVD Looping Problem

Hey if someone could please help me with this code bit that is simply not working

MY goal is to loop through each list projects (ie in the variable ProjectName) and store them a specific file. So right now I only have one. So my goal in this case is to load from SP2 Project Sample.xml and then take the table Field_Table and store it in c:\LANDESK\TEST\CurrentDateField_Table.qvd . Below it is storing it in c:\ so any help is appreciated

thanks, Jason

The Code:

SET Directory[1] = c:\;
SET ProjectName[1] = SP2 Project Sample.xml;
SET ProjectPath[1]=LANDESK\TEST;
LET ProjectCount=1;
LET CurrentDate = date(today(),'YYMMDD');

for a = 1 to ProjectCount
//LOAD all tables in to QVDs based on a filename convention of FileName and Current Date
Field_Table:
LOAD
$(CurrentDate) as Field_Table.CurrentDate,
FieldID,
FieldName,
Alias,
Guid
FROM [$(Directory$(1))$(ProjectPath(1))\$(ProjectName$(1))](XmlSimple, Table is [Project/ExtendedAttributes/ExtendedAttribute]);
SET FileName = $(CurrentDate)Field_Table.qvd;
STORE Field_Table INTO [$(Directory(1))$(ProjectPath(1))\$(FileName)];
DROP TABLE Field_Table;
next a

1 Reply
Not applicable
Author

Hi Canadian

A variable declared as Directory[1] is not an array with the first (or second?) element 1 but a variable called "Directory[1]".

You can see this looking at the variables in Settings/Variable Overview after your load attempt.

So "Directory(1)" will return null as it is unknown syntax. Unfortunately the Load scripts bear many traps.

I suggest you set a variable within the loop that contains your expected file name, then simply use that variable in the store command.

You can also single step through your script and will see with each step the variables content.

Good luck

Juerg