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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
lmonincx
Creator II
Creator II

how to use for each ..next to load data from file

Hi,

Iam struggeling to use a for each .. next statement in order to load every 50th record into a tabel.

I have a file containing thousends of lines and i need a script to load the 1 line then the 51 line then 101 line ..etc ( everytime 50 rows further).

any suggestions how this for each .. next would look like?

thanks for any help!

Linda Monincx

5 Replies
Not applicable

Hi Linda,

Try this instead of a loop:

LOAD ...

FROM ...

WHERE mod(RECNO() / 50) = 1;

This takes the record number of that in the input table, divides by 50 and compares the remainder to 1.

Hope this helps.

Regards,

Gordon

Not applicable

whoops! That should read:

WHERE mod(RECNO(), 50) = 1;

lmonincx
Creator II
Creator II
Author

Thanks that works when i start with my first row, but what if i want to extract the 43 row and then row 93?

Linda

llauses243
Creator III
Creator III

Hi Linda,

A variant ... WHERE mod(RECNO() + 49, 50) = 1;

Luis

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Linda,

these are all variations of the same idea - use RecNo() within the WHERE clause to form your conditions:

where exists(MyFavoriteNumbers, Recno())

or

where match(RecNo(), 37, 43, 467) > 0

etc...

Using for each ... loop in your case would be extremely slow... Gordon's idea will work much better.