I have a PostgreSQL table, which i'm loading on QGIS Essen, that relates many rows to the same object and all this rows have distinct values in the field i'm labelling the objects with. Hence, when I turn on the labels and check the "allow colliding labels", my labels collide (of course!).

I want to be able to draw all labels and actually be able to read them so i'm thinking about automatically displacing them.

I've thought about having a field with a serial number for those rows that are related to the same object and then using it as the displacement "unit", but with a 50k> table, it seems like a tedious job.

Maybe there is an alternate solution?

1 Answer 1


You could collect all distinct values for your groups and aggregate them in the db and create a new table. You will get a new field with aggregated strings. And you actually use those for the labeling.

SELECT string_agg(field_with_distinct_values, '?') FROM table
GROUP BY field_for_the_relate

You then join this table in Qgis and use in the "labeling options" - "formatting" to have a line break for the character ? (or any other you used for the string aggregation). This way they should end up as a list.


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.