I have a large feature dataset with thousands of entries. Each entry is represented by a polygon. The most have unique values in all fields but some of them have to be merged based on a identity number in a field (zip code). I want to merge these polygons without losing the other field values. Is there a operation for this in QGIS?

here is a a screenshot of the aggregate function: aggregate function

1 Answer 1


You can use Menu Processing / Toolbox / Aggregate for this. See the documentation: https://docs.qgis.org/3.16/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#aggregate

To keep all attribute values, you can concatenate them. This works well for string (text) fields. If you have integers, you must convert them to string using to_string("attribute") (replace attribute with the name of the respective attribute). Don't forget to set the resulting field-type to text and define a field-length long enough to include all values:

enter image description here

  • Thanks for the fast answer. I will check this tomorrow morning and post a update. Aug 12, 2021 at 19:43
  • I could need some help getting this to work. What function of aggregate would be the way to go to keep all the field values. There is a bunch (sum, concencate collect,...) of them and I am not very into these functions. Aug 13, 2021 at 7:34
  • Can you post a screenshot of your attribute table (or provide sample data)?
    – Babel
    Aug 13, 2021 at 7:36
  • 1
    What you added is the aggregate dialog window, not the attribute table. Never mind: see updated answer.
    – Babel
    Aug 13, 2021 at 8:33
  • 1
    You might split your layer into those with duplicates and those without and then apply the aggregation on only the duplicates. Then merge the two sets back together. This expression will get the duplicates: Count(1,"ID")>1 replacing ID with your zip code field
    – John
    Aug 13, 2021 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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