1

I've created a new field and used @rownumber to have a numbered index starting from 1. However, when I delete a feature of the layer, the numbered index is assigned once again to all the features so that I cannot preserve the initial numbers for each feature. Is there a way to preserve the numbered index even if some fetaures are deleted later?

3
  • 2
    Have you created a virtual field? because if you have then this is the reason the numbering changes since it is a calculated field and the value is not actually stored in the layer. you need to create a new regular field to store the @rownumber
    – Kalak
    Commented Oct 18, 2023 at 8:47
  • I've created a new field and then used the expression. Maybe I have to create the new field and use the expression at the same time in the field calculator
    – JoanB
    Commented Oct 18, 2023 at 8:55
  • 2
    it doesn't make a difference as long as you have not created a virtual field. If it is a "normal" field then there is no reason for the assigned values to change. (the calculated value is stored, not the expression that will be calculated on the fly which is what virtual fields do)
    – Kalak
    Commented Oct 18, 2023 at 9:40

1 Answer 1

0

Try maximum("ID-field")+1, provided your ID-field is of type integer.

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.