1

I want to add a serial number starting from 0.000 to the attribute table using the field calculator. How can implement it?

2
  • 4
    You simply want to add a row number? 1, 2, 3, ...
    – Bera
    Commented Nov 21 at 9:18
  • 4
    Do you want to increase the number by steps of 0.001? So 0.001, 0.002, ... And is the row order fixed?
    – Fjedsen
    Commented Nov 21 at 9:22

1 Answer 1

8

Variant 1: In the order of the features

Create a new field using the Field Calculator and this expression:

(@row_number - 1)/1000

This creates intervals of 0.001. Change the number of 1000 to create other intervals. This creates increasing values in the order the features are saved (the order in which they were initially created).

Variant 2: In an order based on attribute values

If you want to get the numbers based on another sort order, based on the content of an attribute field (here: id_new), use this expression:

(array_find(array_sort(array_agg(id_new)), id_new))/1000

Left: variant 1, right: variant 2
enter image description here

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