Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ankitbisht01
Creator
Creator

Generating the values for missing dates

Hi all,

I have one challenge with my data set, that is:

-------> I have data regarding  Account numbers , in form of status = 0 or 2.

-------> That data is present only of some dates on which these above status were given or updated.

-------> All i want to generate the current  status for each date of calendar regarding a particular Account Number till the status changes ,

          After change in status, this status will be generated for further dates, till the status changes again.

example : This example is for a particular account number  and i have several account number in my data.

  

Account NumDateStatus
C000013/31/20100
C000014/20/20150
C000014/25/20152

data is like this for each Account Number , i want to have status "0" from date 3/31/2010 - 4/20/2015 for each date comes in between and Status "2" for date 4/20/2015 - 4/25/2015.

I am using master calendar to generate all the dates.

Attaching the data set.

Best Regards

Ankit

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this:

Temp1:

LOAD [Account Num],

     Date,

     Status

FROM

     [data.xls]

     (biff, embedded labels, table is Sheet1$)

     ;

Result:

NOCONCATENATE

LOAD

     [Account Num],

     Date(Date + IterNo() -1,'M/D/YYYY') as Date,

     Status

WHILE

     Date(Date + IterNo() -1) <= PrevDate

     ;

LOAD

     [Account Num],

     Date,

     Date(If(Previous([Account Num]) = [Account Num] and Previous(Status)=Status,Previous(Date)-1),'M/D/YYYY') as PrevDate,

     Status

RESIDENT

     Temp1

ORDER BY

     [Account Num],

     Status,

     Date desc

     ;

DROP TABLE Temp1;


talk is cheap, supply exceeds demand
ankitbisht01
Creator
Creator
Author

Thank you for such a quick response Gysbert,  but script doesn't seems to be working .

Not able to get all the dates with right status .

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

//données de base

Flux_A:

LOAD *

Inline [

Account Num, Date, Status

C00001, 31/03/2010, 0

C00001, 20/04/2015, 0

C00001, 25/04/2015, 2

]

;

//récup min max pour le calendrier

_TMP:

LOAD

  Min(Date) as min,

  max(Date) as max

Resident Flux_A

;

LET vmin = Peek('min');

LET vmax = Peek('max');

//calendrier

CAL:

LOAD

  Date($(vmin) + RecNo() - 1) as _Date

AutoGenerate($(vmax) - $(vmin)) +1

;

//interval

Join(Flux_A)

IntervalMatch(_Date)

LOAD

  Alt(Previous(Date), Date) as Date_déb,

  Date as Date_fin

Resident Flux_A

;

DROP Tables _TMP, CAL;

Aurélien

Consultant Excelcio

Help users find answers! Don't forget to mark a solution that worked for you!