Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
nelsonhbs
Partner - Contributor
Partner - Contributor

Buscar a linha anterior via script

Bom dia pessoal,
Tenho a seguinte situação:
Data, ID_Conta_Banco, Saldo
01/01/2019, 001000100001, 100
02,01/2019, 001000100001, Null
03/01/2019, 001000100001, Null
04/01/2019, 001000100001, 111
05/01/2019, 001000100001, 123
01/01/2019, 001000100002, Null
02,01/2019, 001000100002, 200
03/01/2019, 001000100002, Null
04/01/2019, 001000100002, 222
05/01/2019, 001000100002, Null

Preciso que a coluna Saldo seja preenchida com valor da linha anterior quando a mesma for NULL e quando o ID_Conta_Banco mudar não pode pegar o valor da linha anterior, nesse caso tem que ser ZERO.

2 Replies
Wlad_Masi
Employee
Employee

A função Above() pode te ajudar a pegar o valor anterior, porém você precisará de um if statement validando o ID com o ID anterior.

To help users find verified answers, please don't forget to mark a correct resolution or answer to your problem or question as correct.
afurtado
Partner Ambassador/MVP
Partner Ambassador/MVP

LOAD
Data,
ID_Conta_Banco,
if(num(Saldo) > 0,1,2) as Saldo_Ori,
if(ID_Conta_Banco = Previous(ID_Conta_Banco),if(num(Saldo) > 0,Saldo,peek(Saldo_Atual)),if(num(Saldo) > 0,Saldo,0)) as Saldo_Atual
Inline [
Data, ID_Conta_Banco, Saldo
01/01/2019, 001000100001, 100
02/01/2019, 001000100001, Null
03/01/2019, 001000100001, Null
04/01/2019, 001000100001, 111
05/01/2019, 001000100001, 123
01/01/2019, 001000100002, Null
02/01/2019, 001000100002, 200
03/01/2019, 001000100002, Null
04/01/2019, 001000100002, 222
05/01/2019, 001000100002, Null
];

 

2019-04-23 13_38_19-Qlik Sense Desktop.png

furtado@farolbi.com.br