Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

FileBaseName() issue

Hi all

I need some help with load scripts. I have a standard load script loading some data from excel ,and i try to set the year for a specific file , but something is wrong.

When the "Test(opened)2014-01-01-06-00-26.XLS" was loaded the "year_test" field should be '2013' , but always show 2014

if(

(FileBaseName()='Test(opened)2014-01-01-06-00-26.XLS')

,'2013',

Year(Date#(left(subfield(FileBaseName(),')',2), 10), 'YYYY-MM-DD'))

) AS year_test,

Can you help me with this issue?

Thanks in advance

1 Solution

Accepted Solutions
Sokkorn
Master
Master

Hi,

It return 2014 is correct. Because FileBaseName() will return Test(opened)2014-01-01-06-00-26

You can use

if(

(FileBaseName()='Test(opened)2014-01-01-06-00-26')

,'2013',

Year(Date#(left(subfield(FileBaseName(),')',2), 10), 'YYYY-MM-DD'))

) AS year_test,

Regards,

Sokkorn

View solution in original post

3 Replies
Sokkorn
Master
Master

Hi,

It return 2014 is correct. Because FileBaseName() will return Test(opened)2014-01-01-06-00-26

You can use

if(

(FileBaseName()='Test(opened)2014-01-01-06-00-26')

,'2013',

Year(Date#(left(subfield(FileBaseName(),')',2), 10), 'YYYY-MM-DD'))

) AS year_test,

Regards,

Sokkorn

Sokkorn
Master
Master

Load * from Test(opened)2014-01-01-06-00-26.XLS;

FileBaseName() -> Return Test(opened)2014-01-01-06-00-26

FileName() -> Return Test(opened)2014-01-01-06-00-26.XLS

Not applicable
Author

Thank you very much Sokkorn!!