Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Andrea_001
Contributor II
Contributor II

Expand a table to all date of year

Hi at all,

I have a table like this:

tbl01:

IDVALUEDATE
231001/02/2018
232002/04/2018

 

I'd  like to 'expand' it to another table where the ID and VALUE is replicated for all date, until next change of date, like this: 

tbl02:

IDVALUEDATE
231001/02/2018
231002/02/2018
231003/02/2018
231004/02/2018
231005/02/2018
231006/02/2018
231007/02/2018
2310…..
232002/04/2018
232003/04/2018
232004/04/2018
232005/04/2018
232006/04/2018
232007/04/2018
232008/04/2018
232009/04/2018
2320
232031/12/2018

 

Can someone help me ?

Thank you in advance

Andrea

1 Solution

Accepted Solutions
martinpohl
Partner - Master
Partner - Master

here's a script

Data:
LOAD * INLINE [
ID, VALUE, DATE,
23, 10, 01/02/2018
23, 20, 02/04/2018
];

Temp:

load
date(rowno() + num('01/02/2018') -1) as DATE
AutoGenerate (num('02/04/2018')-num('01/02/2018')+1);

left join load Distinct ID
resident Data;

outer join (Data) load * resident Temp;

drop table Temp;

Sort:
NoConcatenate
load
ID,
VALUE,
DATE
resident Data
order by ID, DATE;

drop table Data;

Addeddata:
NoConcatenate
load
if(isnull(VALUE) and ID = Previous(ID) ,peek('VALUE',-1),VALUE) as VALUE,
ID,
DATE
resident Sort;

drop table Sort;

Regards

Martin

View solution in original post

4 Replies
Andrea_001
Contributor II
Contributor II
Author

Thanks,

my problem is not filling missing values, but generate new record date between two existing date

I've searched but I don't find a solution

 

 

Or
MVP
MVP

martinpohl
Partner - Master
Partner - Master

here's a script

Data:
LOAD * INLINE [
ID, VALUE, DATE,
23, 10, 01/02/2018
23, 20, 02/04/2018
];

Temp:

load
date(rowno() + num('01/02/2018') -1) as DATE
AutoGenerate (num('02/04/2018')-num('01/02/2018')+1);

left join load Distinct ID
resident Data;

outer join (Data) load * resident Temp;

drop table Temp;

Sort:
NoConcatenate
load
ID,
VALUE,
DATE
resident Data
order by ID, DATE;

drop table Data;

Addeddata:
NoConcatenate
load
if(isnull(VALUE) and ID = Previous(ID) ,peek('VALUE',-1),VALUE) as VALUE,
ID,
DATE
resident Sort;

drop table Sort;

Regards

Martin