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

Store data in QVD by date

Hello,

I have the following case: I need to store data by date in QVDs.

Example:

Table:

IDDate
11-Jan-2015
212-Jan-2015
313-Jan-2015
422-Jan-2015

I want to create QVD each 10 days. I mean the first QVD will be from 1 Jan to 10 Jan. The second from 11 Jan to 21 Jan etc.

So the ID 1 witll be stored in the first QVD(1JanTo10Jan), ID 2 and 3 in the second QVD(11JanTo21Jan), and ID 4 in another one(22JanTo1Feb).

Is it feasible? if Yes how? and thank you in advance.

Nancy

1 Reply
maxgro
MVP
MVP

Table:

load ID, Date(Date#(Date, 'D-MMM-YYYY')) as Date inline [

ID, Date

1, 1-Jan-2015

2, 12-Jan-2015

3, 13-Jan-2015

4, 22-Jan-2015

];

for y=2015 to 2016

for m=1 to 12

for d=1 to 30 step 10

       if $(d)=21 then

            let df=day(MonthEnd(MakeDate($(y), $(m), $(df))));

       ELSE

            let df=$(d)+10-1;

       ENDIF;

       trace $(y) $(m) $(d) $(df);

       [$(y)_$(m)_$(d)]:

       NoConcatenate load * Resident Table

       Where Date >= MakeDate($(y), $(m), $(d)) and Date <= MakeDate($(y), $(m), $(df))

       ;

       if NoOfRows('[$(y)_$(m)_$(d)]') > 0 then

            STORE [$(y)_$(m)_$(d)] into '$(y)_$(m)_$(d).qvd' (qvd);

       ENDIF;

       DROP Table [$(y)_$(m)_$(d)];

NEXT

NEXT

NEXT