Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

rmdnkevin
New Contributor III

Create Fields from File Name

Hi.

I have a problem to create some fields such as year and month from file name.

I'm using 201801 for the file name, 2018 indicates the year and 01 means the month.

Can anyone help me how to do this ?

Thanks a lot

- Kevin -

Tags (2)
1 Solution

Accepted Solutions
MindaugasBacius
Valued Contributor III

Re: Create Fields from File Name

Use the FileBaseName() function:

Load *

     ,Right(FileBaseName(), 4) as Year

     ,Left(FileBaseName(),2) as Month

From

xslx

;

View solution in original post

3 Replies
ujjwalraja
New Contributor III

Re: Create Fields from File Name

Hi Kevin,

You can use the left and right function to achieve this.

For Example-

Left(201801,4) will give you 2018 i.e the Year

Right(201801,2) will give you 01 i.e the Month.

Note- To get filename in the script you can use the FileBaseName() function.

Let me know if it fulfils your requirement.

MindaugasBacius
Valued Contributor III

Re: Create Fields from File Name

Use the FileBaseName() function:

Load *

     ,Right(FileBaseName(), 4) as Year

     ,Left(FileBaseName(),2) as Month

From

xslx

;

View solution in original post

rmdnkevin
New Contributor III

Re: Create Fields from File Name

Thanks a lot for the answer