Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
yura_ratu
Contributor II

Filename as a column value

Every day I received reports from partners with standard name "blabla_<PartnerName>_blabla_<date>.csv". Which have same columns. How can I add Two columns -- Partner and Date, which will be filled by values from filenames?

1 Solution

Accepted Solutions
Not applicable

Re: Filename as a column value

Hi Yuriy

filename()   function will return blablabla_partner_blabla_date.csv

subfield function will get string delimited by '-'

so

load

subfield(filename(), '-', 2)   as partner,

subfield(filename(), '-', 4)   as date

FROM ...

best regards

chris

5 Replies
Not applicable

Re: Filename as a column value

Hi Yuriy

filename()   function will return blablabla_partner_blabla_date.csv

subfield function will get string delimited by '-'

so

load

subfield(filename(), '-', 2)   as partner,

subfield(filename(), '-', 4)   as date

FROM ...

best regards

chris

preminqlik
Valued Contributor II

Re: Filename as a column value

subfield(filebasename(),'_',-1)                         as               Date,

subfield(filebasename(),'_',-3)                         as               Partner

chiru_thota
Valued Contributor

Re: Filename as a column value

You can use FileName() function and sub field function to capture the Patner name and Date.

Ex:

Load *,FileName() as FN ..............

yura_ratu
Contributor II

Re: Filename as a column value

It works. Thanks Cristian

sudeepkm
Valued Contributor III

Re: Filename as a column value

Please take a look at the example.

Community Browser