[Qgis-user] Fwd: error on counting inside a map

Dario C dario955i at gmail.com
Sun Jun 6 01:20:37 PDT 2021


I tested and in a standard layout it works very well.
Now I'm trying to use it in a report, where I have a grid and each page
follows the grid piece, ordered by crescent "ID". Even in the report, if I
consider what I see in the map_extent, it is working. But, in my case,
considering the grid is a little bit smaller than the map window (because I
need overlap), I need a filter on intersection with the geometry of the
grid.

Grid in my report is: 'Grid_layer', "ID_Field", 'ID_value' (such as A1, A2,
B1, etc.)

instead to have
aggregate( *'LAYERID*','count',"*KEY-FIELD*","*SPECIFIC-FIELD*" is not
null AND intersects($geometry,map_get(item_variables('Mappa1'),'map_extent')))

I'd like to use intersects with the current value of the ID shown in that
page of the report
something like
... AND  intersects($geometry,get_feature ('Grid_layer',"ID_Field",'*value*
'))))

The problem is that 'value' (attribute of the piece of the grid) is a
variable.
Is there any way to call the current value of the grid in a report
(@element or something like that) or am I using a totally wrong expression?

Thanks in advance for your support.

cheers

Il giorno ven 4 giu 2021 alle ore 14:55 Dario C <dario955i at gmail.com> ha
scritto:

> Thank you DelazJ, it is working well!
> there was a "," instead of AND condition!!!
>
> Just a bit slow but it is working well!
>
>
> I appreciate
>
> Il giorno gio 3 giu 2021 alle ore 17:00 DelazJ <delazj at gmail.com> ha
> scritto:
>
>> Hi Dario,
>> You want two filters: a field not being null and features being visible.
>> But none of your expressions indicates that.
>> Naming parameters could help you avoid falling in this trap (read the tip
>> just above this section
>> <https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/expression.html#some-use-cases-of-expressions>
>> in the docs)
>> try with
>> aggregate( *'LAYERID*','count',"*KEY-FIELD*","*SPECIFIC-FIELD*" is not
>> null *AND*
>> intersects($geometry,map_get(item_variables('Mappa1'),'map_extent')))
>>
>> Hope that helps,
>> Harrissou
>>
>> Le jeu. 3 juin 2021 à 11:38, Dario C <dario955i at gmail.com> a écrit :
>>
>>>
>>> Sorry, I don't want to spam anybody. I send again my request, just in
>>> case it never has never sent.
>>> Thank you
>>>
>>>
>>> Hi,
>>> I'm trying to have a legend on my layout and I'd like to count the item
>>> shown in the legend which are inside the map extent.
>>>
>>> I'm using this expression but:
>>> case 1) it gives me the total amount of the items (not filtered by map)
>>> case 2) it gives me the total amount of the items shown in the map, but
>>> not filtered by field
>>>
>>>
>>> case 1:
>>>
>>> aggregate( *'LAYERID*','count',"*KEY-FIELD*","*SPECIFIC-FIELD*" is not
>>> null, intersects($geometry,map_get(item_variables('Mappa1'),'map_extent')))
>>>
>>> result: 1965 (the same of the total *"SPECIFIC-FIELD" is not null* in
>>> the project (not in the map)
>>>
>>>
>>> case 2
>>>
>>> aggregate( '*LAYERID*','count',"*SPECIFIC-FIELD*" is not null,
>>> intersects($geometry,map_get(item_variables('Mappa1'),'map_extent')))
>>>
>>> result: 583 (total amount of the items in the map, but not of that
>>> specific category)
>>>
>>>
>>> Difference between Case 1 and Case 2 is that case 2 has not "filtered
>>> by" values in the formula.
>>>
>>>
>>> Thank you for your support.
>>>
>>>
>>> Cheers
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210606/b14a69d1/attachment.html>


More information about the Qgis-user mailing list