Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

jsimmonstx
Contributor

Adding a field to a table

I have a table. For the sake of example, let's say it's created like so:

MyTable:

LOAD Myfield1, Myfield2, Myfield3

RESIDENT SomeOtherTable;

I wanted to add a sequential record number to the table, so I tried this:le:

MyNewTable:

LOAD *, RECNO() as RecordID

RESIDENT MyTable;

It added the RecordID field, but it used seemingly random values - 4, 8, 11, 15 instead of the expected 1,2,3,4.

In order to get the desired result, I had to do this:

MyNewTable:

LOAD Myfield1, Myfield2, Myfield3, RECNO() as RecordID

RESIDENT MyTable;

I consider this to be a bug (among the many other bugs your product has). Oh wait, the trainer refused to call stuff like this a "bug", preferring instead to call it a "nuance".

4 Replies
gupta_n8
Valued Contributor II

Re: Adding a field to a table

Use Rowno() instead of RECNo()

Re: Adding a field to a table

Is there a where statement when you did a resident load??

What do you get when you use RowNo() instead of RecNo()?

MyNewTable:

LOAD *, RowNo() as RecordID

RESIDENT MyTable;

vikkyv
Contributor II

Re: Adding a field to a table

Try using the rowno() instead of record number.

RecNo or RowNo?

Re: Adding a field to a table

Hi,

do you have a sample application+data to demonstrate the issue?

This example doesn't seem to show this behaviour:

QlikCommunity_Thread_226020_Pic1.JPG

MyTable:

LOAD RecNo() as Myfield1,

    Ceil(Rand()*100) as Myfield2,

    Ceil(Rand()*100) as Myfield3

AutoGenerate 20;

MyNewTable:

LOAD *, RECNO() as RecordID

RESIDENT MyTable;

DROP Table MyTable;

thanks

regards

Marco

Community Browser