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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Stop load after first record

Hello,

I'm reading a file whose first record is just ahead showing the date the file was created. The second record is the field list and the rest is data. My first step is to load the file to get the date from the first record and load it into a variable, which will be used to show the user how current the data is. After that, it's a normal load of the data. Here what the script does...

FindDate:
LOAD
@2 AS InvHistInfoFileDate
FROM
[$(vDataFolder)\QlikBillingInfo.txt] (ansi, txt, delimiter is ';', explicit labels, msq)
WHERE
RecNo()=1;

LET vInvHistInfoFileDate = num(peek('InvHistInfoFileDate', 0, 'FindDate'));

DROP TABLE FindDate;

It works perfectly, but I'm finding it takes a long time to get the date. I'm guessing that it's reading the entire file just to find out there's only one record with RecNo()=1.

Any ideas on how I can make the load script actually stop after the first record and move on?

Thanks,
Dino

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Dino,
Use this:
First 1;
LOAD
...
(I often use "first 100" for script testing to avoid long load.)

View solution in original post

5 Replies
Anonymous
Not applicable
Author

Dino,
Use this:
First 1;
LOAD
...
(I often use "first 100" for script testing to avoid long load.)

Not applicable
Author

Yep, that did it...I was even able to do away with the WHERE clause.

That was way too simple - somehow, I'm thinking I should have already known how to do this. 😞

Thanks,
Dino

Anonymous
Not applicable
Author

That's not a problem. I'm still finding, after many years using QV, things and solutions I don't know, sometimes simple... Big Smile

Not applicable
Author

Hi,

I would suggest you try the "first" function. simply put First 1 before Laod and it will only laod one record. I have not tested it but it's worth a try I think.

Not applicable
Author

sorry guys I did not see that Michael ahd already replied to this. Big Smile