Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
EduardoAlexandredeFrancisco

Criar Dados Faltantes

Amigos, boa tarde.

Estou com a seguinte demanda e não estou conseguindo resolver.

Cenário:

Base:

Load * Inline

[Filial,NF]

1,0001

1,0002

1,0004

2,0088

2,0089

2,0090

2,0091

2,0003

3,1001

3,1003

3,1004

3,1006

];

Nota que:

- Para a Filial 1, não existe a NF 0003

- Para a Filial 3, não existe a NF 1002  e 1006

Dúvida:

Como faço para fazer o QlikView:

1 - Identificar que tem NF faltando, ou seja, o numero da nota fiscal é o numero anterior + 1

2 - Fazer o QV criar essas NF faltando.

Obs

Preciso fazer isso no load devido a qto de registro.

Deve ficar assim o meu resultado final

NoConcatenate

Base_Faltante:

Load * Inline

[Filial,NF]

1,0003

3,1002

3,1005

];

Labels (1)
1 Solution

Accepted Solutions
maxgro
MVP
MVP

1.png

Base:

Load rowno() as id, * Inline [

Filial,NF

1,0001

1,0002

1,0004

2,0088

2,0089

2,0090

2,0091

2,0003

3,1001

3,1003

3,1004

3,1006

];

Left join (Base)

load

  id,

  Filial,

  if(Peek(Filial)=Filial, -(NF-Previous(NF))) as Delta

Resident Base

order by id desc; 

New:

NoConcatenate

load id, Filial, NF, Delta

Resident Base

where Delta > 1;

left join (New)

load

  id,

  Filial,

  num(NF + iterno(),'0000') as NewNF

Resident New

while iterno() <= (Delta-1);

DROP Field id, Delta;

  

View solution in original post

2 Replies
maxgro
MVP
MVP

1.png

Base:

Load rowno() as id, * Inline [

Filial,NF

1,0001

1,0002

1,0004

2,0088

2,0089

2,0090

2,0091

2,0003

3,1001

3,1003

3,1004

3,1006

];

Left join (Base)

load

  id,

  Filial,

  if(Peek(Filial)=Filial, -(NF-Previous(NF))) as Delta

Resident Base

order by id desc; 

New:

NoConcatenate

load id, Filial, NF, Delta

Resident Base

where Delta > 1;

left join (New)

load

  id,

  Filial,

  num(NF + iterno(),'0000') as NewNF

Resident New

while iterno() <= (Delta-1);

DROP Field id, Delta;

  

EduardoAlexandredeFrancisco
Author

Perfeito.. Obrigado!!!!

Deu certo!!!