Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

for each ... next using field values

Hi guys ... I need some help for the following problem.

I want to  use a for each ... next loop with values of a field. Inside the loop I am using the loop variable to control a where clause.

My code is looking like this:

NoConcatenate Test:

Load Distinct

Concat(DISTINCT A, ', ') as MyList

From Data.qvd (qvd);

for each MyVar in MyList

some command ...

load

...

Where A = '$(MyVar)';

...

Next

Now Qlikview ignores my comma segmented list (MyList) and take MyList as one value.

What am I doing wrong?

1 Solution

Accepted Solutions

Re: for each ... next using field values

You need extra single quotes inside the list.

But a better way to do this is:

 

Test:

NoConcatenate

Load Distinct A From Data.qvd (qvd);

for vRow = 1 to NoOfRows('Test')

   Let MyVar = Peek('A',vRow-1,'Test');

   some command ...

   load

   ...

   Where A = '$(MyVar)';

   ...

Next

//HIC

2 Replies

Re: for each ... next using field values

You need extra single quotes inside the list.

But a better way to do this is:

 

Test:

NoConcatenate

Load Distinct A From Data.qvd (qvd);

for vRow = 1 to NoOfRows('Test')

   Let MyVar = Peek('A',vRow-1,'Test');

   some command ...

   load

   ...

   Where A = '$(MyVar)';

   ...

Next

//HIC

Not applicable

Re: for each ... next using field values

Thanks ... works fine

Community Browser