I'm trying to calculate the shared area for several overlapping areas. I need a dynamic solution in order to get automatically calculated statistics when drawing new polygons.
The target area is in this case the layer which contains the zoning plans. The other layer specifies the type of landuse (Markanvändning). The ultimate goal is to have a virtual field in the zoning layer, which grabs the information from the landuse-layer to define the share of different landuse-types (area) within the plan.
((aggregate(layer:='Markanvändning_e90475ff_88be_43f2_8eae_b14419c74d08', aggregate:='sum', expression:= (area(intersection($geometry, geometry(@parent)))), concatenator:=',', filter:= "kategori" IS 'Offentlig'))/ "area_DP")*100
My approach was to create a virtual field within the zoning plan layer with an aggregate function, which calculates the share with the help of an intersect function. I created a test-layer and everything works fine if I just have one zoning-plan, but when I draw several plans I just get a result for the first row in my zoning plan layer.
What is going wrong here?