Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

MVP
MVP

rowno() not working if preceding load added

Hi all,

if I use something like this in the script:

LOAD recno() as ID, rowno() as Test

AutoGenerate 5;


I get values 1 to 5 in field Test, as expected, right?

ID, Test

1,1

2,2

3,3

4,4

5,5

Why does this break (IMHO) if I add a preceding load?

LOAD *;

LOAD recno() as ID, rowno() as Test

AutoGenerate 5;

returns (tested in QV 11SR1 and some older versions)

ID, Test

1,0

2,0

3,0

4,0

5,0

Any ideas?

Thanks

Stefan

P.S. I noticed, that asking 'why' might not be the right questions to ask here in the community, but I am just curious, maybe someone knows...

Adding to this, I am essentially not interested in workarounds to get Test count from 1 to 5 like in

LOAD ID, rowno() as Test

LOAD recno() as ID

AutoGenerate 5;

but to understand if this is a bug in the software or in my understanding of it.

4 Replies
Not applicable

Re: rowno() not working if preceding load added

Hi Stefan,

I'm asking myself the same question.

Did you discover why?

Thanks!

Patrick

jaimeaguilar
Valued Contributor II

Re: rowno() not working if preceding load added

Hi,

I think this behavior is counter intuitive, but may be normal behavior (I don't know). I've seem this in the past and I think that preceding loads cannot be used together with autogenerate/while statements.

For example if you modify the code to do the following, QV will loop forever:

Table:    

LOAD *;

LOAD recno() as ID, rowno() as Test

AutoGenerate 1

while RowNo()  <=5;

however, if you remove the preceding load from any of the examples, it will work as expected,

really weird,

regards

Re: rowno() not working if preceding load added

I think I can explain this.

RowNo() is the output table row number. The top LOAD statement defines the output, so RowNo() can only return a valid result there.

-Rob

http://masterssummit.com

http://robwunderlich.com

chematos
Valued Contributor II

Re: rowno() not working if preceding load added

After reading an explanation about how preceding load works, I think the result you have is because in preceding load the process of each record takes place in each iteration, so RowNo() is always its first value for each iteration.

This is the explanation I think it is the most accurate:

"hic Mar 6, 2013 2:31 PM (en respuesta a qlikviewed)

Let's say that you have the following construction:

          Load *, SomeFunction(X,Y) as Z; // Load statement "B"

          Load X, Y From ... ;            // Load statement "A"

Then each record that is loaded by "A" is piped into "B". This means that "B" processes the first record completely before "A" starts to process the second record. In other words: the result of "A" is never stored as a table - neither on disk, nor in RAM. So you can't say that "B" loads a table from RAM or from disk.

"

Regards,

-Jose

Community Browser