Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Ron1
Partner - Creator
Partner - Creator

Conditional Weekly Load QlikSense

I have below qvd files in my source folder.

I want to load files from  2019 Week 48 on wards. Please help me to form the scripting

Data_2019_Week45.qvd
Data_2019_Week46.qvd
Data_2019_Week47.qvd
Data_2019_Week48.qvd
Data_2019_Week49.qvd
Data_2019_Week50.qvd
Data_2019_Week51.qvd
Data_2019_Week52.qvd
Data_2020_Week1.qvd
Data_2020_Week2.qvd
Data_2020_Week3.qvd
Data_2020_Week4.qvd
So on…..

1 Solution

Accepted Solutions
Taoufiq_Zarra

Hi,

I know there are many ways to do this,
but I propose you a gymnastics solution (because I love this game 😁)

if I load the initial data ( I added a field to see what I loaded )

Capture.JPG

I get the result

Capture.PNG

 

there are two elements in the filenames the year and the week.
so I use those two elements to create a date.
and then before loading the qvd file I check if the created date (which is in the qvd file name) is higher than your reference date which is week 48 of 2019

so the scrip is :

let week48=MakeWeekDate(2019,48);
for each File in filelist ('.\test2\*.qvd')
       let vmatch = MakeWeekDate(num(TextBetween('$(File)','Data_','_Week')),num(TextBetween('$(File)','_Week','.qvd'))) ;
       if '$(vmatch)'>'$(week48)' then
       
			Data:
			
			LOAD *
			
			FROM
			$(File)
			(qvd);
		end if
next File

and the result :

Captu2re.JPG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

2 Replies
Taoufiq_Zarra

Hi,

I know there are many ways to do this,
but I propose you a gymnastics solution (because I love this game 😁)

if I load the initial data ( I added a field to see what I loaded )

Capture.JPG

I get the result

Capture.PNG

 

there are two elements in the filenames the year and the week.
so I use those two elements to create a date.
and then before loading the qvd file I check if the created date (which is in the qvd file name) is higher than your reference date which is week 48 of 2019

so the scrip is :

let week48=MakeWeekDate(2019,48);
for each File in filelist ('.\test2\*.qvd')
       let vmatch = MakeWeekDate(num(TextBetween('$(File)','Data_','_Week')),num(TextBetween('$(File)','_Week','.qvd'))) ;
       if '$(vmatch)'>'$(week48)' then
       
			Data:
			
			LOAD *
			
			FROM
			$(File)
			(qvd);
		end if
next File

and the result :

Captu2re.JPG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Ron1
Partner - Creator
Partner - Creator
Author

It works like a charm. Thanks 🙂