4

I have a table with two fields: "NUMBER" (integer) and "TOWN" (text). I would like to find an expression that fills the "NUMBER" field with an automatic number specific for each value of "TOWN".

Example:

NUMBER | TOWN
----------------------
1      | STRASBOURG
2      | STRASBOURG
3      | STRASBOURG
1      | PARIS
2      | PARIS
1      | TOULOUSE
2      | TOULOUSE
3      | TOULOUSE
4      | TOULOUSE

How can I do that with a QGIS expression?

1

1 Answer 1

7

Finally, I found the right expression to do that:

"TOWN" || (@row_number - minimum(@row_number, "TOWN") + 1)

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.