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

Complet data

hi everyone, 

I have a table with dates and prices in which I want to fill in the days without value with the previous value, for example:

my data

DatePrice
01/01/202155,34
05/01/202156,79
06/01/202157,99
07/01/202159,25
08/01/202160,80
11/01/202161,99
12/01/202163,80
15/01/202164,40

 

desired data

DatePrice
1/1/202155,34
2/1/202155,34
3/1/202155,34
4/1/202155,34
5/1/202156,79
6/1/202157,99
7/1/202159,25
8/1/202160,80
9/1/202160,80
10/1/202160,80
11/1/202161,99
12/1/202163,80
13/1/202163,80
14/1/202163,80
15/1/202164,40

 

thanks

1 Solution
4 Replies
Saravanan_Desingh

One Solution is,

tab1:
LOAD *,Peek(tDate) As pDate, tDate-Peek(tDate) As Diff;
LOAD *,Date(Date#(Date,'DD/MM/YYYY')) As tDate;
LOAD * INLINE [
    Date, Price
    01/01/2021, "55,34"
    05/01/2021, "56,79"
    06/01/2021, "57,99"
    07/01/2021, "59,25"
    08/01/2021, "60,80"
    11/01/2021, "61,99"
    12/01/2021, "63,80"
    15/01/2021, "64,40"
];

Join(tab1)
LOAD Date(pDate+IterNo()-1) As tDate
Resident tab1
While IterNo()<=Diff+1;

tab2:
NoConcatenate
LOAD tDate, If(IsNull(Price), Peek(Price), Price) As Price
Resident tab1
Order By tDate;

Drop Table tab1;
yassinemhadhbi
Creator II
Creator II

 

a:LOAD * INLINE [
Date,Price
01/01/2021,55,34
05/01/2021,56,79
06/01/2021,57,99
07/01/2021,59,25
08/01/2021,60,80
11/01/2021,61,99
12/01/2021,63,80
15/01/2021,64,40];

b:LOAD *,Previous(Date) as d
RESIDENT a

order by Date desc
;
drop table a;
NoConcatenate
table:LOAD * resident b order by Date asc;

drop table b;

 

NoConcatenate
Dates:
Load
Price,
Date( Date + IterNo() - 1 ) as Date
Resident table
While IterNo() <= d - Date ;

drop table table

 

Best Regards
Yassine Mhadhbi
tincholiver
Creator III
Creator III
Author

Thanks to both, the solution that worked is Saran7de's while Yassinemhadhbi's
does not take the value of the last day:

that solution gives this result:

Date Price
01/01/2021 55
2/1/2021 55
3/1/2021 55
4/1/2021 55
05/01/2021 56
06/01/2021 57
07/01/2021 59
08/01/2021 60
9/1/2021 60
10/1/2021 60
11/01/2021 61
12/01/2021 63
13/1/2021 63
14/1/2021 63

Thank you very much too