In QGIS, I have a vector layer with a field listing the names of several polygons features.
I want to calculate the sum of the areas of the polygons in this list, using Field Calculator and displaying the result.
For example my table is :
Names | list of polygons | area | result field: sum of areas |
---|---|---|---|
A | 10 | 0 | |
B | A,C | 20 | 15 |
C | 5 | 0 |
For now I tried using the following function but it doesn't work:
array_sum(
array_foreach(
string_to_array("list of polygons", ','),
area(@element)
)
)
but it returns NULL
everywhere.
I also tried with :
array_sum(
array_foreach(
string_to_array("list of polygons", ','),
$area
)
)
but this gives the area of the current feature.
Any idea where is my mistake?