QGIS Attribute Table – Showing Data from Attribute Table in Legend

attribute-tablelegendpoint-in-polygonqgis

I have multiple points with locations on a map and I want to calculate the exact number of points for a selected area.
I created a polygon and with Numbers of points on the polygon I created a new layer which in the attribute table contains the number of points in the polygon.

attribute table

I want to export the map as an image. I used Print Layout but I don't know how to add the number of points from the attribute table to the legend.

enter image description here

Best Answer

You can use the following expression if there is one polygon.

@layer_name  +  ' (' + 
  to_string(array_get(array_agg( "NUMPOINTS" ), 0))
+ ')'

enter image description here

Related Question