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: 
379SSS
Contributor III
Contributor III

Load only Latest two months files

Hi All,


Can anyone help me on below requirement.


I have multiple Qvd files with naming as below

1.Products_New_202201.qvd
2.Products_New_202112.qvd 
3.Products_New_202111.qvd
4.Products_New_202110.qvd

Here I need to load only latest two months files from the folder also files don't have the date fields.

please help me on this 

Labels (3)
1 Solution

Accepted Solutions
Kushal_Chawda

@379SSS  try below

let vFolderPath ='lib://Store QVD/Data';

Files:
first 1 LOAD
SubField(FileBaseName(),'_',-1) as FileMonth,
FileName() as FileName
FROM [$(vFolderPath)/Products_New_*.qvd]
(qvd);

Latest2Months:
first 2 load FileName
Resident Files
Order by FileMonth desc;

Drop Table Files;

Data:
Load 0 as Temp
AutoGenerate 0;

for i=1 to FieldValueCount('FileName')

let vFileName = FieldValue('FileName',$(i));

Concatenate(Data)
Load *
FROM [$(vFolderPath)/$(vFileName)]
(qvd);

Next

Drop Field Temp;

Drop Table Latest2Months;

View solution in original post

2 Replies
Kushal_Chawda

@379SSS  try below

let vFolderPath ='lib://Store QVD/Data';

Files:
first 1 LOAD
SubField(FileBaseName(),'_',-1) as FileMonth,
FileName() as FileName
FROM [$(vFolderPath)/Products_New_*.qvd]
(qvd);

Latest2Months:
first 2 load FileName
Resident Files
Order by FileMonth desc;

Drop Table Files;

Data:
Load 0 as Temp
AutoGenerate 0;

for i=1 to FieldValueCount('FileName')

let vFileName = FieldValue('FileName',$(i));

Concatenate(Data)
Load *
FROM [$(vFolderPath)/$(vFileName)]
(qvd);

Next

Drop Field Temp;

Drop Table Latest2Months;

379SSS
Contributor III
Contributor III
Author

Thanks! @Kushal_Chawda . It's working now 😊