I have made a print layout containing a map and 2 different vector layers. 1 polygon and 1 point layer.

I have used til polygon layer to control my atlas function.

The polygons are fields and the points are samples of the soils within the polygon. I have 51 fields each containing a number of points.

Can I make a dynamic text containing the average value of a colomn from the point layer's attribute table? Only showing the average number of the field, that the layout shows.

1 Answer 1


Use this expression to calculate the mean value of the field value from layer points, but only for points features overlapping the current atlas feature:

array_mean (overlay_intersects ('points',"value"))

only points in the current field/atlas feature are considered, points in other fields (here e.g. 7 and 14) are ignored: enter image description here

  • That was very helpfull. There is a small difference from the calculatet number in qgis to the real number. But I think it happens because the attributtabel is rounding decimals to the field. Note to myself, i can´t you layername, i have to click on maplayer and at the layer from there. I can´t just write rt_2022, which is my layer name.
    – Jonas
    Commented Nov 21, 2023 at 6:40
  • For rounding errors, check, check field length. If the answer solved your problem, consider accepting it (hit the checkmark next to it)
    – Babel
    Commented Nov 21, 2023 at 6:50
  • Where is the check field length?
    – Jonas
    Commented Nov 21, 2023 at 7:09
  • See here, but go to the tab fields: gis.stackexchange.com/a/470634/88814 when you create a new field, you can define length and decimal precision of a decimal field. Precision 2 means that 2.543 is rounded to. 2 digits: 2.54
    – Babel
    Commented Nov 21, 2023 at 7:33
  • Allright. I have made this where til polygonlayerlabel is rule based and should show the averagenumber of the points within the field (RT Gns:). ('Rt Gns:' || '\n' || round(array_mean(overlay_intersects('Terra_Agro_jordpr_ver_2023_8344da87_94a0_45be_abd1_b251a4dafee1',"Rt")),2) But the average number is not 5,78 bur closer to 6,2. [![enter image description here][1]][1] [1]: i.sstatic.net/k29sK.png
    – Jonas
    Commented Nov 22, 2023 at 8:22

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.