Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load file name as field in table

Hi,

I am loading multiple files from the same folder using *.  Is there any way of taking the name of each file and adding as a field within the table?

Thanks in advance,

James

1 Solution

Accepted Solutions
erichshiino
Partner - Master
Partner - Master

Sure,

You just need to change the order and some parameters, like this:

Let us say that your cross table is like this:

CrossTable(Name, Value,3)

Load *

From ...

You change it to:

CrossTable(Name, Value,4)

Load filename() as fileName, *

From ...

Hope this helps,

Erich

View solution in original post

6 Replies
erichshiino
Partner - Master
Partner - Master

Hi,

You can include some functions in the load, like this:

Load *, filename() as Filename

From *.txt (txt);

or you can use Filebasename()

Hope this helps,

Erich

Not applicable
Author

what you are looking for might be the file Functions eg.:

LOAD

     *,

     filename() as LoadFile

FROM *.QVD (qvd) ;

ther more available like filedir() etc. which you can find in the help.

Not applicable
Author

Thanks Erich, I have tried this on a standard load and it works fine.  Is there any way of doing this on a Crosstable load?

erichshiino
Partner - Master
Partner - Master

Sure,

You just need to change the order and some parameters, like this:

Let us say that your cross table is like this:

CrossTable(Name, Value,3)

Load *

From ...

You change it to:

CrossTable(Name, Value,4)

Load filename() as fileName, *

From ...

Hope this helps,

Erich

Not applicable
Author

Yes that works perfectly, many thanks for your help.

James

Not applicable
Author

Hi

Similar to it  can resident load possible with the above statement as i had mentioned below, i tried doing it ,gets reloaded without any error but couldn't get any values after the reload... pls help

TABLE1:

CrossTable(DATE1, Data,2)

LOAD

  LEFT(FileName (),6) AS FileDate,

  Name,

     [1],

     [2],

     [3],

     [4],

     [5],

     [6],

     [7],

     [8],

     [9],

     [10],

     [11],

     [12],

     [13],

     [14],

     [15],

     [16],

     [17],

     [18],

     [19],

     [20],

     [21],

     [22],

     [23],

     [24],

     [25],

     [26],

     [27],

     [28],

     [29],

     [30],

     [31]

FROM

[032014.xls]

(biff, embedded labels, table is DATA$);

TABLE2:

LOAD *

Resident TABLE1;

DROP Tables TABLE1;