In QGIS, I have a polygon-layer with communes. Some communes consist of different parts (exclaves). I want to merge all parts of the same communes to one object. How is it possible to define which values from the attribute-table (inhabitants) is collected as the attribute-value of the new multi-polygon? Some parts of my input layer have NULL-values - I want to avoid them and always take the value that is not NULL, but QGIS seems to select always the first value.
In the attribute-table, the no. of inhabitants is specified only in the main polygon (center of commune), not in the exclave (often actuylla uninhabited). In a schematic way, here is how my data looks like - part 2 is exclave of part 1, part 3 exclave of part 4:
part 1 : commune-id 435 : inhabitants: 2853 part 2 : commune-id 435 : inhabitants: NULL part 3 : commune-id 729 : inhabitants: NULL part 4 : commune-id 729 : inhabitants: 3517
I now perform
select geometries to merge all parts that belong to the same political body (commune) to one object, thus I create multipolygons, based on a field "commune-id". Works well, but not all values for inhabitants in the resulting layer are the correct ones. Merging the object above based on commune-id, I get:
part new_a : commune-id 435 : inhabitants: 2853 part new_b : commune-id 729 : inhabitants: NULL
In the second case, the no. of inhabitants should be 3517, not NULL.