1

Given a relation in QGIS 3.x (I have a layer A of points (150 geometries) and an attribute table B of users with 500 records, and each one of this registered users is associated to a point geometry through a relation), is it possible to store in a new field of the layer A (points) the number of registered users that are associated to each point, using the established relation?

1 Answer 1

0

You can summarize your table B to get a new table with one column being the common ID you use for your join and the second column being the count of each ID.

To do that you could use a virtual layer with this SQL query :

SELECT JOIN_FIELD_NAME, COUNT(JOIN_FIELD_NAME) as 'number of users' from TABLE_B Group by JOIN_FIELD

(just replace JOIN_FIELD_NAME and TABLE_B by the actual name).

This new table now has a one to one relationship with your Layer A and and after a join you could update your new field in layer A with the user count, but as a virtual layer is dynamic you should just do a join, this way if you add or remove user your count will stay up to date

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.