Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to use name of loadable file as dimension

Hi,

I would like to load the table files to QV, to view them there. The source producing those files does not add the important for me dimensions like month and country name. We have 12 months and I get the files for 3 countries (Poland, Hungary and Slovakia). i would like to name those files so that I could know what month and country they contain, so for instance for Jan, Poland, I would use 01_PL.xls, for Aug and Hungary, i would have 08_HU.xls

I was thinking to use 2 first digits of the loading file name and 2 last as content for month and Country dimensions for the data of the given file loaded. This way by small effort I would get 2 very important dimensions...

Could you help me to have something like that?

Thanks a lot in advance

//Draszor

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can use a wildcard in the file from spec like this:

FROM *.xls

And then use the FileBasename() function in your LOAD like this:

LOAD

  *,

   subfield(FileBasename(),'_',1) as Month,

   subfield(FileBasename(),'_',2) as Country

...

-Rob

http://robwunderlich;com

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can use a wildcard in the file from spec like this:

FROM *.xls

And then use the FileBasename() function in your LOAD like this:

LOAD

  *,

   subfield(FileBasename(),'_',1) as Month,

   subfield(FileBasename(),'_',2) as Country

...

-Rob

http://robwunderlich;com

Not applicable
Author

Dear Rob,

Thanks a lot, this works perfectly!