2

I have the following attribute table and I wish to show the total area in hectares seperate to my attribute table on the print setup. I currently have to add these values manually. Is there a way to get QGIS to calculate this automatically?

enter image description here

Corentin Lemaitre
  • 3,003
  • 5
  • 17
  • aggregate(layer:='your layer',aggregate:='sum',expression:="area" should work - but it doesn't, and I don't know why. Aggregate is a ... very challenging expression- – Erik Apr 29 '21 at 13:30

1 Answers1

1

The aggreagate formula don't work well in the layout, I have faced this issue also.

The solution I found is to do it in two steps, first creating a virtual field and then show in the layout a table with one cell.

  1. Create a virtual field in your layer that will contain the total of the area in your layer. Here is the formula : aggregate( @layer , 'sum', $area ). The area would be calculated directly from your geometry. It will be updated if you add or modify geom. You can check the result and modify the formula to show round number or Ha.
  2. When the result is the one you want you can add a table in your layout, select your layer and choose to show only the field you just made and show no header and filter only the first entry.
Corentin Lemaitre
  • 3,003
  • 5
  • 17