Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gopikrishnach
Creator
Creator

how to dynamically load the latest qvd in the folder in qlikview

Hi All,

How to load the latest qvd from the folder.

ex: i have  qvds in that folder like:

                                                     sample_20190331_0.qvd

                                                     sample_20190331_1.qvd

                                                     sample_20190331_2.qvd

                                                     sample_20190430_0.qvd

                                                     sample_20190430_1.qvd

                                                     sample_20190530_0.qvd

                                                     sample_20190530_1.qvd

i want to load that particular  the month wise Latest number .qvd ,not all,into my app.

like for March i want to load sample_20190331_2.qvd, for April i want load sample_20190430_1.qvd

how to achieve this?

13 Replies
martinpohl
Partner - Master
Partner - Master

Hi,

you can use this script:

for each file in filelist('..\..\Support\Daten\sample_*.txt')

Temp:
load
FileName() as file,

subfield(FileBaseName(),'_',2) as month,
subfield(FileBaseName(),'_',3) as version
from '$(file)';

next


left join (Temp)
load
month,
max(version) as maxversion
resident Temp
group by month;

 

Filestoload:
load
file
resident Temp
where version = maxversion;

for loop = 0 to NoOfRows ('Filestoload')-1
let loadfile = peek('file',$(loop),'Filestoload');

Data:
load
*
from ..\..\Support\Daten\'$(loadfile)'
;

next


drop table Temp;
drop table Filestoload;

gopikrishnach
Creator
Creator
Author

Hi Sunny,

Thank you very much for your valuable time to resolve my isaue. I have quick questions, after loading of all qvd in loop, i have to create a final qvd with that data. Please help me out bow to resolve this.

Regards,
Gopi Krishna CH.
sunny_talwar

Add STORE FinalTable into xyz.qvd (qvd); after DROP statement at the end.

priyasawant
Creator II
Creator II

Hi,

This is giving me proper output I am able to retrieve the latest reloaded file but now I also want to load the 2nd last file and concate with each other.

 

Let me know how can i get the second latest file also...

 

Thanks in advance.