Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
leni_balakrishn
Contributor III

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

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Identify the end of file

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

7 Replies
Not applicable

Re: Identify the end of file

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

leni_balakrishn
Contributor III

Re: Identify the end of file

Thanks Alex.

Let me try this solution and get back to you

sivarajs
Valued Contributor II

Re: Identify the end of file

Use this in load statement

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

leni_balakrishn
Contributor III

Re: Identify the end of file

Thanks Sivaraj

Not applicable

Re: Identify the end of file

Did you already get a right answer?

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

Regards,

Alex

leni_balakrishn
Contributor III

Re: Identify the end of file

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

Re: Identify the end of file

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

Community Browser