5

uniq

I tried a lot by Field Calculator but it gives me NULL as you show in table and another try it gives me value 1 in all rows.

Most of examples, on internet they are explaining old version and I have QGIS 3 and I am not sure how can I add id for all rows .

If I want to generate random id, how can I do it also.

I did as suggested in answer $id

enter image description here

But could i ask why the values are not looks like counter, it looks random. If i need to increase by one, how can i do that?

3

2 Answers 2

8

The easiest and preferred way is to use the processing algorithm "Add Autoincremental Field"

2
  • where can i fnd it ,i looked for it but i did not know,where is it located
    – potter90
    Commented Feb 3, 2020 at 14:46
  • 3
    Processing -> Toolbox and search for it. Commented Feb 3, 2020 at 14:49
3

The simplest answer is the $id variable.

Be careful though, it doesn't auto-increment after your first field calculation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.