Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

rec() creating duplicate rows

Hi.

I am running into an interesting situation. I have a table which is a result of concatenating three loads coming from three different sources (A, B, C). I then include rec() into the load so that I will have a unique number per row. Oddly this step is resulting in multiple instances of the same rows for records I loaded from B and C. I checked the sources for B and C and there are no duplicates. For testing, I also tried displaying in a simple Table Box of all the fields from that Table and did not see any duplicates. But when I reload the table with a new field such as rec() as recID suddenly the loaded table is having multiple identical rows.

Any ideas?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Got it fixed Sunny! Don't know why I hadn't thought about it but this time I did Load Distinct. I realize for the data from sources B and C I was doing a simple Load while the data from source A I had Load Distinct.

Still no idea though why I'd have to put Distinct in the load script as they're all unique anyway.

View solution in original post

6 Replies
sunny_talwar

Have you tried with RowNo() instead of RecNo()?

RowNo() as RecID

Anonymous
Not applicable
Author

Tried just now and still having the same result. I'm perplexed. Very odd.

sunny_talwar

Would you be able to share the script don't need the field names... but a basic outline

Anonymous
Not applicable
Author

Got it fixed Sunny! Don't know why I hadn't thought about it but this time I did Load Distinct. I realize for the data from sources B and C I was doing a simple Load while the data from source A I had Load Distinct.

Still no idea though why I'd have to put Distinct in the load script as they're all unique anyway.

marcus_sommer

If you used a logic like this:

table:

load *, rowno() as RowNo, recno() as RecNo inline [

F1, F2

a, 1

b, 2

];

concatenate(table)

load *, rowno() as RowNo, recno() as RecNo inline [

F1, F2

c, 3

d, 4

];

concatenate(table)

load *, rowno() as RowNo, recno() as RecNo inline [

F1, F2

e, 5

f, 6

];

it will work or is anything different in your logic?

- Marcus

marcus_sommer

Distinct is not important to the functionalities of rowno/recno but it could have an impact to all merged tables not only the one in which is was declared.

- Marcus