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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
BenjaminCoe1440
Contributor III
Contributor III

Handling nulls within a loop

I'm getting this error when I try to loop through a list of clients to bring back their account level qvds. It should work like this: variable picks up AccountName from a list from a table called 'Client List', this variable then is input into a qvd filename within a loop, returning the records for that account from the qvd (stored earlier).
 
I'm currently getting a null coming through or "". So the loop errors when it can't find something called "_readings", because it should look like "[companyname]_readings". There are no nulls in the ClientList, so I need to exclude nulls instead but I'm not sure how to do that.
 
 
The following error occurred:
Cannot open file: 'lib://Admin - Account Data Files:DataFiles/_readings.qvd' (Connector error: File not found)
 
 
Here is the loop:
 
for it_accounts=0 to $(vNumRows)
let vAcc=peek('AccountId',$(it),'temp_clientlist');
let vAccountName=peek('AccountName',$(it),'temp_clientlist');
let vFileAccountName=lower(replace('$(vAccountName)',' ',''));
 
 
This is where I enter the variable:
load *
FROM [lib://Admin - Account Data Files:DataFiles/$(vAccountName)_readings.qvd]
(qvd);
 
 
Labels (2)
1 Reply
marcus_sommer

I assume that vNumRows is something like noofrows() and contained the number of records of the table. In this case the index starts by 1 whereby the index of peek() starts by 0 and therefore the loop runs one too often. Just adjust it by:

for it_accounts=0 to $(vNumRows) - 1