Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Scripting Issue

I have a folder which conatins many csv files with names such as aaa MAY 2014, aaa Jun 2014 and so on.

How do i load only those csv files which are received after MAY 2014.

4 Replies
Not applicable
Author

If the file name contains the month name, you can use the function FilebaseName() to get the name of the file and filter.

johanlindell
Partner - Creator II
Partner - Creator II

Convert the part of the FilebaseName() with the "date" in it into a date and the check this date if you should proceed:

LET fileDate = Date(Date#('01 MAY 2014', 'DD MMM YYYY'), 'YYYY-MM-DD')

This will return a date for that you can compare with in an IF statement.

Not applicable
Author

I have a requirement of loading a particular field from the csv file only after June 2014. For the previous years that field is not present in the file.

I have used this expressoin

if(date(date#(textbetween(lower(Filename()),'data', '.csv'),' MMM YYYY'),'MMM YYYY')>'May 2014', FieldName,'') as FieldName

the above expression throws up an error Field not found.

Anonymous
Not applicable
Author

Hi,

this won't work in your loadstatementn because QlikView will interprete FieldName as if there is a field with that name resulting in Error if not. There are a several ways to do that.

Depending on your script you could try (if you are looping through all files with filelist() for example) a control statement, using different loads:

if date(date#(textbetween(lower(subfield('$(vFile)', '\', (substringcount('$(vFile)', '\')+1))),'data', '.csv'),' MMM YYYY'),'MMM YYYY')> date(MakeDate(2014, 5), 'MMM YYYY') then

load

*,

FieldName

From $(vFile);

else

load

*

From $(vFile);

endif

Hope this helps.

Best regards

Stefan