Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

New Contributor II

Duplicate key and the Inputfield

I have a table in my  application containing a long detailed sales history  data.

I use an inputfield to be able to simulate changes in profit by means o adjusting the GM%.

When I load the table in  older  QV  (v9) there is no issue.

I had to continue the development in a separate PC (out of server) with QV v.10 ,

When I load the script , it ends with an error :

Duplicate keys when loading  Input Field

and the applicatiom re-starts

This happend only in QV v.10.

When I delete the line with INPUTFIELD (load w/o the Inputfield),  the script runs OK in QV10 (but I cannot use inputsum of course)

1) What does that error mean and why only in a newer QV?

2) how to find the root couse of the error?

original script:









6 Replies
Valued Contributor II

Duplicate key and the Inputfield

Internally, QlikView uses all the non-inputfield fields from the table to create a composite primary key for each inputfield value. (starting in QV10)

Your error indicates that some records have the same combination of the non-inputfields.

For example a table A has the fields: X, Y, Z and W. W is declared as an Inputfield. The problem will occur if there are two or more records with the same combination of values for the fields X, Y and Z. This is because when you change one input value in field W, QlikView will not be able to correctly assign the value.

So answering your questions:

1. This problem happens only in QV10 because inputfields functioned differently in QV9.

2. You need to ensure that there are no duplicate records in the non-inputfield fields.

Hope I was able to explain it clearly...



Not applicable

Duplicate key and the Inputfield

Or you can add the result of the function RowNo() as a field to your 'SmartPlain' table. This will ensure that every row is unique once it's loaded in and avoid the error.

Honored Contributor II

Re: Duplicate key and the Inputfield

Fantastic explanation that really helped me just now.  Thanks Fernando!

Not applicable

Re: Duplicate key and the Inputfield

Hi Fernando,

And what about my example? Could you please have a look to the attched qvw? !

Valued Contributor II

Re: Duplicate key and the Inputfield

Hi Eleni,

Conceptually your app has the same error. Since you only created one field which was declared as an inputfield, QlikView doesn't have a non-inputfield field to create a key. You must create another field with a unique number for each row.

Valued Contributor

Re: Duplicate key and the Inputfield

Just in case,

I solved this problem by adding additional field with rowno()

RowNo() AS AddKey



Community Browser