3

I want to create an expression in the QGIS 3.28 dashboard layer that counts points on a specific point_layer and with a specific value that is displayed in the current map_extent view

aggregate(
   layer:='point_layer', 
   aggregate:='count', 
   expression:="field1", 
   filter:="field1"='3' AND within(.. ???.. )
   )
6
  • 1
    you can use the function from this post to get the current extent as a geometry
    – JGH
    Commented Dec 3, 2023 at 14:49
  • i dont want to create virtual layer
    – Rii Pii
    Commented Dec 3, 2023 at 17:35
  • 1
    you cans till create and use the function :)
    – JGH
    Commented Dec 3, 2023 at 21:31
  • 2
    Please be aware you have a spelling mistake in your expression. whithin should be within.
    – Matt
    Commented Dec 4, 2023 at 7:08
  • 1
    See this section of the documentation for how to define and use a custom function.
    – Matt
    Commented Dec 4, 2023 at 7:28

1 Answer 1

3

The @map_extent variable returns the current extent:

aggregate(
   layer:='point_layer', 
   aggregate:='count', 
   expression:="field1", 
   filter:="field1"='3' AND within(@geometry, @map_extent)
   )
1
  • thank you webrian & Taras ... it is working well
    – Rii Pii
    Commented Dec 5, 2023 at 10:49

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.