Qlik Community

Ask a Question

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Do More with Qlik - for Beginners and Beyond, Topic: Qlik Replicate on January 21, 2PM EST. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Where put data table name in do while function

Hi

I have the next script but when I refresh I'm not able to create the table name so in the concat function I got the error in the final image.

Where should I put the name? Or should I use a function to do so?

Let vNumeroPagina=1;

do while vValorFinal>2

[VentasDiarias]:

LOAD
Período

FROM [XXXXX]
(html, codepage is 1252, embedded labels, table is @$(vNumeroPagina));


Let vValorFinal=len(peek('Período',-2,'VentasDiarias'));
Let vNumeroPagina=$(vNumeroPagina)+1;

Loop

Concatenate (VentasDiarias)

LOAD
Período

FROM [xxxxxxx]
(ooxml, embedded labels, table is Sheet1);
Drop Table;

Captura de Pantalla 2020-01-02 a la(s) 7.56.11 p. m..png

 

 

Labels (3)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

My guess is that it is not going into the loop at all as you are not initialising vValorFinal and it is not getting set until inside the loop.

Ahead of the code you have, try adding:

let vValorFinal = 9999;

If you have a load and you are not sure whether a table exists before you concatenate to it you can always create a dummy table:

MyTable:
LOAD
  null() as tmpDummy
AUTOGENERATE(1);

Then at the end:

DROP FIELD tmpDummy;

This should create a table stub that can then be concatenated to. It's a bit of a cheat, but it works.

A neater, but fiddlier, alternative is to do the table name in a variable:

let vTabName = if(alt(NoOfRows('MyTable'), 0) > 0, 'CONCATENATE (MyTable)', 'MyTable:');

$(vTabName)
LOAD
   ... etc ...

Hope that helps.

Steve

View solution in original post

3 Replies

I feel on the first run the initial table is not created or loaded with zero records before the concatenation statement is executed , could you please share the complete log file ? 

MVP & Luminary
MVP & Luminary

My guess is that it is not going into the loop at all as you are not initialising vValorFinal and it is not getting set until inside the loop.

Ahead of the code you have, try adding:

let vValorFinal = 9999;

If you have a load and you are not sure whether a table exists before you concatenate to it you can always create a dummy table:

MyTable:
LOAD
  null() as tmpDummy
AUTOGENERATE(1);

Then at the end:

DROP FIELD tmpDummy;

This should create a table stub that can then be concatenated to. It's a bit of a cheat, but it works.

A neater, but fiddlier, alternative is to do the table name in a variable:

let vTabName = if(alt(NoOfRows('MyTable'), 0) > 0, 'CONCATENATE (MyTable)', 'MyTable:');

$(vTabName)
LOAD
   ... etc ...

Hope that helps.

Steve

View solution in original post

Anonymous
Not applicable

The drop field worked perfectly