Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Hi guys, Concatenation using loops

Hi guys,

i am using this script to concatenate files using loops, but with this loop there are many concatenations taking place and my data model doesn't look good...please help me how to avoid that using auto increment

//concate

FOR Each vfile in FileList('C:\Users\w_318460\Desktop\New folder\*.xlsx')

Concat:

LOAD

  * from [$(vfile)]

(ooxml, embedded labels, table is Sheet1);

Concatenate

LOAD

* from [$(vfile)]

(ooxml, embedded labels, table is Sheet1);

NEXT vfile

Thanks

Yogesh

18 Replies
swuehl
MVP
MVP

Could you detail what your issue is?

For example, how does your data model look like at the end and how do you want it to look like?

How are your input files named and is the structure of the input files the same?

Why do you load the input files twice?

Not applicable
Author

Yea that's what it is loading twice and in my table viewer its showing like concat1,concat2. i want data to be loaded only once , cz i am new to qlikview i donno how to use auto increment ..so please help me how to do so.

my input files are named as emp1,emp2,emp3 etc.,

thanks Stefan for ua reply.

swuehl
MVP
MVP

What do you mean with auto increment? Which value do you want to increment?

Not applicable
Author

auto increment in the sense every file should be loaded until it reaches last file.

Gysbert_Wassenaar

What is being incremented? And what makes it auto?


talk is cheap, supply exceeds demand
Not applicable
Author

It should take every excel file one by one for that we need to use increment i guess.. i am not sure about it...

I will explain you complete scenario.

i have n number of excel files in a folder which will be updating every often...so instead of loading those each and every time i have used loops..but its loading twice..i want that to load only once so give some example script to get that fixed

Gysbert_Wassenaar

FOR Each vfile in FileList('C:\Users\w_318460\Desktop\New folder\*.xlsx')

Concat:

LOAD

  * from [$(vfile)]

(ooxml, embedded labels, table is Sheet1);

 

Concatenate

LOAD

* from [$(vfile)]

(ooxml, embedded labels, table is Sheet1);

 

NEXT vfile

Inside the loop you execute the same load twice. You load the data twice from the same file. That's why you have double the data you want. Remove one of the two load blocks.


talk is cheap, supply exceeds demand
swuehl
MVP
MVP

The FOR EACH ... IN FILELIST() ...NEXT

should take care of iterating over all files in your folder, no need for additional actions

If you want to load the tables only once, then do so (remove the second load). Tables will be auto-concatenated if the structure (field names) is identical in all files:

FOR Each vfile in FileList('C:\Users\w_318460\Desktop\New folder\*.xlsx')

Table:

LOAD

  * from [$(vfile)]

(ooxml, embedded labels, table is Sheet1);

NEXT vfile

Not applicable
Author

If i remove any one of the block i wont get result. say if i remove first one script will fail and if i remove second one next file wont work..

Gysbert can u alter that script and reply me?

Thanks in advance