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

previous balance inflows and outflows and closing balance

I need to create opening balance and ending balance, by date_time, product.

Table OriginalData;

LOAD * INLINE [
DATA_HORA,Filial,Produto,Quantidade,Tipo,
19/02/2022 12:59:27,156,212,150,S
19/02/2022 12:56:22,156,212,75,E
18/02/2022 04:44:13,156,212,75,S
18/02/2022 04:35:19,156,212,27,E

];

Desired result:

FILIAL Produto DATA_HORA Tipo Previous E S Balance
156 212 18/02/2022 04:35:19 E 0 27 0 27
156 212 18/02/2022 04:44:13 S 27 0 75 -48
156 212 19/02/2022 12:56:22 E -48 75 0 27
156 212 19/02/2022 12:59:27 S 27 0 150 -123

 

Order By

Produto,

DATA_HORA,

Filial

 

DROP Table OriginalData;



 

Neves
1 Solution

Accepted Solutions
Thiago_Justen_

Bom dia @Ribeiro,

Veja o resultado do app que anexo a seguir:

Screenshot_20220220-115946_Chrome.jpg

Perdoe a qualidade da imagem mas fiz pelo celular, daí o print não ficou lá grandes coisas...

Abs e Sucesso!!

 

 

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago

View solution in original post

4 Replies
Thiago_Justen_

Bom dia @Ribeiro,

Veja o resultado do app que anexo a seguir:

Screenshot_20220220-115946_Chrome.jpg

Perdoe a qualidade da imagem mas fiz pelo celular, daí o print não ficou lá grandes coisas...

Abs e Sucesso!!

 

 

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
Ribeiro
Specialist
Specialist
Author

😂 só tenho o qlikview por aqui. tem como enviar apenas o script para mim.

obrigado

Neves
Ribeiro
Specialist
Specialist
Author

 


Final:
Load
*,
Alt(Previous(Saldo),0) As Saldo_Anterior
;
Load
*,
If(Previous(Produto)=Produto,
RangeSum(Qtd_Movimento,Peek(Saldo)),
Qtd_Movimento
) As Saldo

;
Load
*,
Pick(Match(Tipo,'S','E'),-Quantidade,Quantidade) As Qtd_Movimento
Resident OriginalData
Order By
Filial,
Produto,
DATA_HORA
Asc
;

Drop Table OriginalData;

 

Neves
Thiago_Justen_

Era isso mesmo... ia mandar agora. 🤘😁

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago