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: 
Tooomooo
Contributor
Contributor

Autocomplete empty records with a previous value

HELO

I have a little problem. I have two views: Master Calendar and Temp

LET vMinDate = Num(MakeDate(2020,9,18));
LET vMaxDate = Num(Today()-1);
LET vDays = vMaxDate - vMinDate + 2;
Master Calendar:
LOAD
date(floor(TimeStamp,0.000694444446708076),'YYYY-MM-DD hh:mm:ss')as CreationDate
;
LOAD
    Timestamp($(vMinDate) + (RecNo() - 1)/1440) as TimeStamp
AUTOGENERATE 1440 * $(vDays);

Temp:
  
LOAD * INLINE [
     CreationDate, Stan
    2020-09-18 00:07:12, A
    2020-09-18 00:10:12, B
    2020-09-18 00:15:12, C
    2020-09-18 00:18:12, D
    2020-09-18 05:22:12, A
    2020-09-18 05:25:12, B
    2020-09-18 08:32:12, C
    2020-09-18 08:34:12, D
    2020-09-18 07:12:00, A
    2020-09-18 08:42:12, B
];
 
 
After reloading the script, I have tables 

 

CreationDateStan
2020-09-17 23:59:12 
2020-09-18 00:00:12 
2020-09-18 00:01:12 
2020-09-18 00:02:12 
2020-09-18 00:03:12 
2020-09-18 00:04:12 
2020-09-18 00:05:12 
2020-09-18 00:06:12 
2020-09-18 00:07:12A
2020-09-18 00:07:12 
2020-09-18 00:08:12 
2020-09-18 00:09:12 
2020-09-18 00:10:12B
2020-09-18 00:10:12 
2020-09-18 00:11:12 
2020-09-18 00:12:12 
2020-09-18 00:13:12 
2020-09-18 00:14:12 
2020-09-18 00:15:12C
2020-09-18 00:15:12 
2020-09-18 00:16:12 
2020-09-18 00:17:12 
2020-09-18 00:18:12D
2020-09-18 00:18:12 
 
 
 
 

How to fill in empty fields in a table with an earlier value. I suppose you have to use the privus function.
But how ???

 
 
5 Replies
rubenmarin

Hi, I've already answered a very similar question here: https://community.qlik.com/t5/New-to-QlikView/Creating-a-master-calendar-and-filling-in-missing-data...

You can use Peek() or Previous() to retrieve the value of the previous record, and use a sorted load to load them by date ("Order by CreationDate" or "Order By CreationDate desc" depending if you want to propagate them forwards or backwards, something like:

Outer Join (Temp)
LOAD CreationDate Resident MasterCalendar;

TempFilled:
LOAD CreationDate,
  If(IsNull(Stan), Peek(Stan), Stan) as StanRICE
Resident Temp
Order By CreationDate;

DROP Table Temp;

 

Tooomooo
Contributor
Contributor
Author

After adding the code and reloading, I saw a view of duplicate values. There are still empty values in the columns StanRICE

 

1.JPG

Brett_Bleess
Former Employee
Former Employee

@Tooomooo It may be most helpful if you can attach a QVW we can look at directly and tweak and reattach at this point to ensure you get the right solution.  @rubenmarin  can you have a second look just to see if you may be able to sort something without the QVW file?  

Cheers,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
rubenmarin

Hi @Tooomooo @Brett_Bleess , probably it needs to be 

If(IsNull(Stan), Peek(StanRICE), Stan) as StanRICE

Chanty4u
MVP
MVP

can you try this?

if(len(trim(StanRICE))=0,Peek('StanRICE'),StanRICE) as StanRICE

or

Use Previous function:

IF(LEN(StanRICE)=0,PREVIOUS(StanRICE),StanRICE) AS StanRICE