Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Jsobrinho77
Creator
Creator

Fill empty values with last not null values

Hi guys,

I have a table, with a column Regra that contains null values, and I need to complete it with the last values, I'm trying to use the code (https://community.qlik.com/t5/QlikView-App-Dev/Fill-empty-values-with-last-not-null-values/td-p/1310...)

try this

 

Data:

LOAD

  ID,

  Task,

  [Start Date],

  [End Date],

  [Workflow Id]

FROM Source;

Final:

noconcatenate

LOAD *,

          if(len(trim([Workflow Id]))=0,peek([Workflow ID]),[Workflow Id]) as [Workflow ID]

Resident Data

order by ID,Task,[Start Date];

My code:

SQL_Sales:
LOAD *,
if(len(trim(Regra))>0,Regra,peek(Regra)) as Value
Resident __SQL_Sales order by CreatedAt DESC;
null.png
But some lines still contain null, how can I solve this?

Labels (4)
1 Reply
vinieme12
Champion III
Champion III

Thats because your source column itself is null! 

here is how peek() works, peek() will look at previous row in your dataset while loading

Date,Regra,Value
2022-04-12,6,6
2022-04-11,6,6
2022-04-10,6,6
2022-04-09,null,6   <---- Here regra is null, so peek(regra) returns the value for 2022-04-10
2022-04-08,null,null  <---- Here regra is null, so peek(regra) returns the value for 2022-04-09
2022-04-07,null,null  <---- Here regra is null, so peek(regra) returns the value for 2022-04-07
2022-04-06,null,null

 

you need to Refer to the value column instead

SQL_Sales:
LOAD *,
if(len(trim(Regra))>0,Regra,peek(Value)) as Value
Resident __SQL_Sales order by CreatedAt DESC;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.