I want to add a serial number starting from 0.000 to the attribute table using the field calculator. How can implement it?
1 Answer
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