Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
evansabres
Specialist
Specialist

Unique File in a Loop Script

Hello -

I have a series of files that I am aggregating together into a QVD file. Each file is named YYYY-MM-DD. I have my script set up to create a loop:

FOR EACH vSecMktList IN FILELIST ('*csv')
SecMktTbl:
Load Distinct
Date,
DATE#(SUBFIELD(Date, ' ',1), 'M/D/YY') AS eventDATE,
//left(Date, 9) AS eventDATE,
Opponent,
Section AS tixCODE,
Row,
Price,
Quantity,
[Sample Date],
Board,
ETicket   
FROM $(vSecMktList) (txt, codepage is 1252, embedded labels, delimiter is ',', msq) WHERE Price <=275;
Next vSecMktList;

What I want to do, is to be able to identify each file in my application. Can I identify each file with a unique identifier, i.e name file 2014-11-02 as Day307, so that in my application, I can create an expression to sum the quantity or average the price while referencing Day307, so as to create a table or chart that shows, as of 2014-11-02, the number of tickets for event date YYYY-MM-DD was x?

Thank you.

1 Solution

Accepted Solutions
marcus_sommer

You could use something like:

filebasename() as Source

to identify the files.

- Marcus

View solution in original post

3 Replies
Not applicable

Hi Evan,

you can use your vSecMktList  within each loop to generate a new field yes.

'Day'&DayNumberOfYear(Date#($(vSecMktList),'YYYY-MM-DD')) AS FileDayNumber

Something like that should work for you and generate you a day number based on each file name within the loop

hope that helps

Joe

marcus_sommer

You could use something like:

filebasename() as Source

to identify the files.

- Marcus

maxgro
MVP
MVP

'Day' & num(DayNumberOfYear(date(left(subfield('$(vSecMktList)', '\', -1),10), 'YYYY-MM-DD')), '000') as FileIId