Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
rmdnkevin
Contributor III
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 -

1 Solution

Accepted Solutions
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

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
Contributor III
Contributor III

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
Partner - Specialist III
Partner - Specialist III

Use the FileBaseName() function:

Load *

     ,Right(FileBaseName(), 4) as Year

     ,Left(FileBaseName(),2) as Month

From

xslx

;

rmdnkevin
Contributor III
Contributor III
Author

Thanks a lot for the answer