How to load QVDs dynamically based on Date and its availability

In general , we will load the data in QVDs with daily basis or monthly basis with suffix.

Sometimes we need to pick latest QVDs and load into the dashboard.

I have QVDs like QVD_2017_01,QVD_2017_02,QVD_2017_03,QVD_2017_04,QVD_2017_04 and so on…

I want to load latest QVDs like last 3 months if it exists.

How to achieve this requirement?

FOR i = 0 to vMaxMonthNumber 
 let Date_Suffix = date(floor(monthstart(today(), -vMaxMonthNumber+i)), 'YYYY_MM'); 
 LET vFileNotAvailable=isnull(QvdCreateTime('$(vQVDPath)\QVD Folder\Table1_$(Date_Suffix).qvd')); // if qvd exists then 0 else -1
 IF not $(vFileNotAvailable) then
 load *
 FROM $(vQVDPath)\QVD Folder\Table1_$(Date_Suffix).qvd (qvd);
 end if 
 LET vFileNotAvailable=isnull(QvdCreateTime('$(vQVDPath)\QVD Folder\Table2_$(Date_Suffix).qvd')); // if qvd exists then 0 else -1
 IF not $(vFileNotAvailable) then 
 load *
 FROM $(vQVDPath)\QVD Folder\Table2_$(Date_Suffix).qvd (qvd);

end if;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.