Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Identify the end of file

Hi friends,

I would like to know whether we can set a field after each document load. Let me explain the scenario in detail below:

I have a set of files in a folder like file1.txt, file2.txt, file3.txt, etc.,

I will be loading these files to the Qlikview like:

Load * from file*.txt;

Now I need to add a field to add the file name that I m loading.

My output should be like,

field1     field2     field3

x          2              file1

y          45            file1

z          8               file2

a          8               file3

I need field, field3 which will be added dynamically.

Or is there any other way to set a value to check end of file and use that in an another load statement.

Thanks in Advance

Thanks,

Leni Balakrishnan

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

You can use the function filename().

example:

Load

Field1,

Field2,

filename() as Field3  //This will store the file name to your field3

from file*.txt

Regards,

Alex

View solution in original post

7 Replies
Not applicable
Author

Hi,

You can use the function filename().

example:

Load

Field1,

Field2,

filename() as Field3  //This will store the file name to your field3

from file*.txt

Regards,

Alex

Anonymous
Not applicable
Author

Thanks Alex.

Let me try this solution and get back to you

sivarajs
Specialist II
Specialist II

Use this in load statement

SubField(Mid(FileName(),Index(FileName(), '\', -1) +1), '.', 1) as file_name

Anonymous
Not applicable
Author

Thanks Sivaraj

Not applicable
Author

Did you already get a right answer?

or is mine or Sivaraj's answer not what you are looking for?

Regards,

Alex

Anonymous
Not applicable
Author

Yes this is the thing I looked for.

But I need to compare this value in an another load statement to check whether the value came from same file or an another file.

Regards,

Leni

Not applicable
Author

Okay, when you finished checking please pick either mine or Sivaraj's answer to close the thread. So other users with the same problem can view the answer.

Thanks and Regards,

Alex