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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
A7R3
Contributor III
Contributor III

How to reset row() in loading multiples file through a For-Next loop

Hi,

I am using the following load script to read Excel spreadsheets organized by date folder.

FOR Each vDir in DirList('$(vDataPath)/*')
   FOR each vFile in filelist (vDir&'\BOM*.xls' ) //New

   TableCompWorkBench:
       LOAD Distinct
       TRIM(Mid(filebasename(), 16)) as Products,
       FileTime() as ReportTime,

       PartNumber
       FROM [$(vFile)] (biff, no labels, header is 10 lines) //New
   Next vFile
Next vDir

I would like to set the counter of the first row in every file loaded to be 1.

I have tried the autonumber function as follow. But it doesn't work. The counter basically keep running 

       AutoNumber(TRIM(Mid(filebasename(), 16))&FileTime()&RecNo()) as Counter,

The input/output expected will as follow.

 Input  Output
File Folder PathProductsReportTimePartNumberCounter
20201201/A.xlsA20201201X11
20201201/A.xlsA20201201X22
20201201/A.xlsA20201201X33
20201201/A.xlsA20201201X44
20201201/B.xlsB20201201X11
20201201/B.xlsB20201201X22
20201201/B.xlsB20201201Y13
20201201/B.xlsB20201201Y24
20210101/A.xlsA20210101X11
20210101/A.xlsA20210101X22
20210101/A.xlsA20210101X33
20210101/A.xlsA20210101X44

 

s there any suggestion from the expert in the forum?

Thanks in advance.

Labels (2)
1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

Hi 
if you just want a counter of records in each file then 
use recno()  with no other function

View solution in original post

3 Replies
lironbaram
Partner - Master III
Partner - Master III

Hi 
if you just want a counter of records in each file then 
use recno()  with no other function

A7R3
Contributor III
Contributor III
Author

Yes. The RecNo() works. I thought the RecNo() is the same as Row() that will continue incrementing the counter. 

Thank you.

Amit
Contributor III
Contributor III

Perfect answer!