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

Simple For loop variable is not working

Hi, I have a simple For loop statement that for some reason will only return one row. For this particular load there are 3 rows in the Tracker table, each with a unique ID (PK_gameId). The Fixture qvd has thousands of rows so I need to reduce it to only the rows containing IDs in the Tracker qvd.

vNumRows evaluates to 3 which is perfect. vFixtures evaluates to the unique ID in the first row. When I load the Fixture table I only get 1 row instead of 3.

 

Tracker:
Load 
PK_gameId
FROM [D:\QlikView\DEV\DBQVD\Soccer\ReportsTracker.qvd] (qvd)
where Report_Status = 0;


let vNumRows =NoOfRows('Tracker');

For i = 0 to $(vNumRows)
LET vFixtures = Peek('PK_gameId',i,'Tracker');

Fixture:

LOAD * 
FROM [D:\QlikView\LIVE\DBQVD\Soccer\db_Fixtures.qvd] (qvd)
where PK_gameId = $(vFixtures);

  

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

Probably need single quotes in where condition

Tracker:
Load 
PK_gameId
FROM [D:\QlikView\DEV\DBQVD\Soccer\ReportsTracker.qvd] (qvd)
where Report_Status = 0;

let vNumRows =NoOfRows('Tracker');

Fixture:
load * inline [
Temp ];

For i = 0 to $(vNumRows)
LET vFixtures = Peek('PK_gameId',i,'Tracker');

concatenate(Fixture)
LOAD * 
FROM [D:\QlikView\LIVE\DBQVD\Soccer\db_Fixtures.qvd] (qvd)
where PK_gameId = '$(vFixtures)';

next

drop field Temp;

 

View solution in original post

3 Replies
Kushal_Chawda

try below

Tracker:
Load 
PK_gameId
FROM [D:\QlikView\DEV\DBQVD\Soccer\ReportsTracker.qvd] (qvd)
where Report_Status = 0;

let vNumRows =NoOfRows('Tracker');

Fixture:
load * inline [
Temp ];

For i = 0 to $(vNumRows)
LET vFixtures = Peek('PK_gameId',i,'Tracker');

concatenate(Fixture)
LOAD * 
FROM [D:\QlikView\LIVE\DBQVD\Soccer\db_Fixtures.qvd] (qvd)
where PK_gameId = $(vFixtures);

next

drop field Temp;
AyCe1082
Creator
Creator
Author

Hi Kush, that almost worked. After it loops through all the rows it doesn't end - it tries to continue looping which results in an error.

AyCe1082_0-1595347984785.png

 

Kushal_Chawda

Probably need single quotes in where condition

Tracker:
Load 
PK_gameId
FROM [D:\QlikView\DEV\DBQVD\Soccer\ReportsTracker.qvd] (qvd)
where Report_Status = 0;

let vNumRows =NoOfRows('Tracker');

Fixture:
load * inline [
Temp ];

For i = 0 to $(vNumRows)
LET vFixtures = Peek('PK_gameId',i,'Tracker');

concatenate(Fixture)
LOAD * 
FROM [D:\QlikView\LIVE\DBQVD\Soccer\db_Fixtures.qvd] (qvd)
where PK_gameId = '$(vFixtures)';

next

drop field Temp;