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

Skip numbers in FOR statement

Sup guys,

I've did a FOR statement to generate a field based on a field that already exists.

[Provimento]:

Load num(min([Mes Provimento]),'000') as Mesmin,

     num(max([Mes Provimento]),'000') as Mesmax,

     min([Ano Provimento]) as Anomin,

     max([Ano Provimento]) as Anomax

Resident [Dados do agrupamento];

let vMesmin = peek('Mesmin',0);

let vMesmax = peek('Mesmax',0);

let vAnomin = peek('Anomin',0);

let vAnomax = peek('Anomax',0);

[SentencaProcessoAux]:

load * inline [

  Provimento, CTSentença

];

for vAnoProvimento = $(vAnomin) to $(vAnomax)

for vMesProvimento = $(vMesmin) to $(vMesmax)

Join ([SentencaProcessoAux])

LOAD num($(vMesProvimento),'000')&'/'&$(vAnoProvimento) as Provimento

      NUMERO_PROCESSO &'|'& COD_COMARCA &'|'& NUM_MOVIMENTO &'|'& DT_MOVIMENTO as CTSentença ,

FROM [$(v_diretorioInterno)\SentencaProcesso.qvd] (qvd)

Where Exists([Provimento Agrupamento],num($(vMesProvimento),'000')&'/'&$(vAnoProvimento));

next;

next;


The problem is, $(vMesmin) is 2 and $(vMesmax) is 22. Nothing wrong with that except theres only a '3' between min and max.

So i've tried to compare with exists before the LOAD statement but nothing happens(the same i did on the Where clause).

Something like

if(Exists([Provimento Agrupamento],num($(vMesProvimento),'000')&'/'&$(vAnoProvimento))) then
LOAD etc etc
Else
next;

Endif;

Ive put the Exists in the end just to make things more faster but it's not really what i want, since it loads again(with 0 values), but it loads.


Any thoughts about it?

1 Reply
Vegar
MVP
MVP

I don't remember the exact syntax but I usually do something like this

For i = 1 to getfieldvaluecount(field)

Select *

Resident table

Where field = getfieldvalue(i)

Next

-Vegar