I'm working with QGIS 3.22. I have two layers of points (layers A and B), and I know how many points of layer B are within a fixed distance from each point of layer A.

I updated a field of layer A with this number using the aggregate function in the field calculator. Refer to Counting number of points in one layer within fixed distance to points in another layer in QGIS.

I would also like to know how to sum the values of one numerical field of layer B for only the points that are within the fixed distance for each of the individual points of layer A. In other words, if Point#1 of layer A has 10 points of layer B within the fixed distance, I would like to make a new numerical field in layer A where summing the numerical values of the 10 points of layer B taken from a chosen field, and repeat this for all the points of layer A with the associated points of layer B.

  • 1
    Try using sum() with the aggregate() expression which was added as an answer to the linked question and with the field you want to sum up as input.
    – Erik
    Mar 13, 2023 at 13:14
  • Thank you. I tried to use the sum() function but did not work. The problem is that you must indicate the field to sum, so the expression must be used on the layer containing the field (in this case layer B), but I want to update layer A. So the expression should identify the points of layer B within a fixed distance from the point of layer A, and extract and sum the information from one of the field of that layer and update a new field in layer A with the summed values, for each point of A according to the related points of B. Mar 13, 2023 at 14:40
  • 1
    Please provide the exact expression you tried.
    – Erik
    Mar 13, 2023 at 16:33
  • Hello, I was able to solve the problem creating a circular buffer with the desired radius around the points of layer A, and using the QGIS tool "Join attributes by location (summary)". Then, I needed to updated a new field in layer A taking the values from the buffer layer using the tool "Join attributes by field value". Probably there was a smarter way to do it using the field calculator, but I was not able to do it. Thank you Mar 14, 2023 at 8:18