I am using the aggregate expression in QGIS to count how often my polygon name appears in another point layer. The 'Polygon_zone_name' exists on both my polygon layer and my points layer, I can successfully count how many times it exists, but I need an additional filter to only count where the attribute field "Materials_Count" = 1 in my point layer. Can't see to get it to work.

    Polygon_Zone_name=attribute(@parent, 'Polygon_Zone_name')
        AND attribute(targetlayer, Materials_Count='1')

1 Answer 1


If I understand correctly you have:

  • A polygon layer called Polygon_layer. It has one string attribute called Polygon_zone_name.
  • A point layer called targetlayer. It has one string attribute called Polygon_zone_name which has identical strings as the polygon layer has in a field named the same. Additionally, this layer has an integer attribute called Materials_Count.

You now want to add the count of appearances of the string in Polygon_Zone_name of the Polygon_layer to the targetlayer if both Polygon_Zone_name strings are identical and the targetlayers attribute Materials_Count is 1.

If that is correct, try this expression:

    filter:="Polygon_Zone_name"=attribute(@parent, 'Polygon_Zone_name')
        AND attribute(@parent, 'Materials_Count')=1
  • Thats worked!! thank you
    – Hibernian3
    Feb 14, 2023 at 21:24

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.