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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dgreenberg
Partner - Specialist
Partner - Specialist

Problem with Loop concatenating variable

I have a loop

For A=2 to 3

  Right Keep

  Sampling2:

  Load

  eEngNumber,

  ePartner,

  [Engagement Start Date]

  Resident Sampling1

  where ePartner <> $(vPartnerB);

   drop table Sampling1;

  let vNumberOfRows2=NoOfRows('Sampling2');

  let vRand=ceil(rand()*$(vNumberOfRows2),1);

  let vEngNumber=peek('eEngNumber',$(vRand),'Sampling2');

  let vPartner=peek('ePartner',$(vRand),'Sampling2');

  let vEngNumber=peek('eEngNumber',$(vRand),'Sampling2');

  Let vPartnerB=chr(39) & peek('ePartner',$(vRand),'Sampling2') & chr(39);

  Let vEngIDs=$(vEngIDs) & ','  & $(vEngNumber);

  Let vPool=$(vPool) & ',' & $(vNumberOfRows2);

  Rename table Sampling2 to Sampling1;

NEXT

The 2 bold lines work the first time through the loop but error the next time through.

qv.png

The first value is is set outside of this loop 2000495901

the first time through the loop it appends to vEngIDs the value 3000071383 and there is no problem yet.

the third and any subsequent times through the loop it errors as shown above.

No other lines have issues

Any thoughts?

1 Solution

Accepted Solutions
sunny_talwar

What if you do this:

Let vEngIDs= '$(vEngIDs)' & ','  & $(vEngNumber);

  Let vPool= '$(vPool)' & ',' & $(vNumberOfRows2);

View solution in original post

2 Replies
dgreenberg
Partner - Specialist
Partner - Specialist
Author

Solved it.  put single qoute around $(vEngIds) and for second one do ',$(vEngNumber)'

Let vEngIDs='$(vEngIDs)' & ',$(vEngNumber)';

sunny_talwar

What if you do this:

Let vEngIDs= '$(vEngIDs)' & ','  & $(vEngNumber);

  Let vPool= '$(vPool)' & ',' & $(vNumberOfRows2);