I make a new column in my attribute table and it has a default value (for example 0). I want to (probably using the Field Calculator) have the result that row 1 has the value 1, row 2=2 and so on, just like a numbered index.
I'd be thankful for a code example for the field calculator (including the use of $rownum
(I think I need this for switching to the line)).
Best Answer
Just put
$rownum
(QGIS 2) or@row_number
(QGIS 3+) as the expression. Simple as that. :)An up-to-date list of all the field calculator functions can be read in the official docs.