Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
WalidChoukri
Contributor III
Contributor III

Populating missing values

Hello Everyone,

I'm trying to Populate missing values of the dates in between with peek function, i used the following code but still i couldn't get the results i'm looking for :

Table:

LOAD * INLINE [
    Date, Article, Quantity
    01/02/2021, A, 10
    03/02/2021, A, 20
    06/02/2021, B, 30
    07/02/2021, C, 40
];

Join(Table)
LOAD
   	Date(MinDate+IterNO ()-1) as Date
While(MinDate+IterNO ()-1) <= Num(MaxDate -1);

LOAD
Min(Date) as MinDate,
Max(Date) As MaxDate
Resident Table;

Join(Table)
Load
If( Len(Quantity) = 0, peek('newQuantity'),Quantity) as newQuantity
Resident Table;

Capture d’écran 2021-03-17 170324.png

I attached my file, any help is much appreciated. Thank you !!

1 Solution

Accepted Solutions
MayilVahanan

Hi @WalidChoukri 

Try like attached file

script:


Table:

LOAD * INLINE [
Date, Article, Quantity
01/02/2021, A, 10
03/02/2021, A, 20
06/02/2021, B, 30
07/02/2021, C, 40
];

DateT:
LOAD
Date(MinDate+IterNO ()-1) as Date
While(MinDate+IterNO ()-1) <= Num(MaxDate);
LOAD
Min(Date) as MinDate,
Max(Date) As MaxDate
Resident Table;

T1:
Load Date as StartDate, Article, Quantity, Date(Alt(Peek(StartDate)-1, Today())) as EndDate Resident Table Order by Date desc;

DROP Table Table;

IntervalMatch(Date)
LOAD StartDate, EndDate Resident T1;

Join
LOAD * Resident T1;

DROP Table T1, DateT;

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

4 Replies
Dalton_Ruer
Support
Support

1. Be sure to sort the data in your final load in date order 

MayilVahanan

Hi @WalidChoukri 

Try like attached file

script:


Table:

LOAD * INLINE [
Date, Article, Quantity
01/02/2021, A, 10
03/02/2021, A, 20
06/02/2021, B, 30
07/02/2021, C, 40
];

DateT:
LOAD
Date(MinDate+IterNO ()-1) as Date
While(MinDate+IterNO ()-1) <= Num(MaxDate);
LOAD
Min(Date) as MinDate,
Max(Date) As MaxDate
Resident Table;

T1:
Load Date as StartDate, Article, Quantity, Date(Alt(Peek(StartDate)-1, Today())) as EndDate Resident Table Order by Date desc;

DROP Table Table;

IntervalMatch(Date)
LOAD StartDate, EndDate Resident T1;

Join
LOAD * Resident T1;

DROP Table T1, DateT;

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
WalidChoukri
Contributor III
Contributor III
Author

Thank you so much for your help

MayilVahanan

Welcome. Happy to help you
Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.