Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
twanqlik
Creator
Creator

Filling missing dates in a table

In the first table below is what is currently available for 1 particular customer in our customer database.

In the second table is what i would like to create. 

All the in between dates need to be filled based on the calendar, and it needs to pick up the first status till the status changes. 

Has someone an idea how to do this? 🙂 

 

Available data:

Customer IDStatusDate
1No20-Mar-19
1Yes17-Mar-19
1No14-Mar-19
1Yes13-Mar-19
1No10-Mar-19

 

Desired output:

Customer IDStatusDate
1No20-Mar-19
1Yes19-Mar-19
1Yes18-Mar-19
1Yes17-Mar-19
1No16-Mar-19
1No15-Mar-19
1No14-Mar-19
1Yes13-Mar-19
1No12-Mar-19
1No11-Mar-19
1No10-Mar-19

 

 

 

 

1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

HI 

this script 

will do the trick foryou

[Table]:
Load *,
date(date#([Date],'DD-MMM-YY')) as startDate ;
LOAD * INLINE
[
Customer ID,Status,Date
1,No,20-Mar-19
1,Yes,17-Mar-19
1,No,14-Mar-19
1,Yes,13-Mar-19
1,No,10-Mar-19
](delimiter is ',');

/// adding the end date for each date

Table2:
load * ,
date( startDate + iterno()-1) as DateList
while date( startDate + iterno()-1) < endDate;
load *,
if(IsNull(Previous(startDate)),startDate+1,previous(startDate)) as endDate
resident Table
order by [Customer ID], startDate DESC;


drop Table Table;

View solution in original post

1 Reply
lironbaram
Partner - Master III
Partner - Master III

HI 

this script 

will do the trick foryou

[Table]:
Load *,
date(date#([Date],'DD-MMM-YY')) as startDate ;
LOAD * INLINE
[
Customer ID,Status,Date
1,No,20-Mar-19
1,Yes,17-Mar-19
1,No,14-Mar-19
1,Yes,13-Mar-19
1,No,10-Mar-19
](delimiter is ',');

/// adding the end date for each date

Table2:
load * ,
date( startDate + iterno()-1) as DateList
while date( startDate + iterno()-1) < endDate;
load *,
if(IsNull(Previous(startDate)),startDate+1,previous(startDate)) as endDate
resident Table
order by [Customer ID], startDate DESC;


drop Table Table;