[Qgis-user] How to filter expression in aggregate

Andrea Giudiceandrea andreaerdna at libero.it
Mon Mar 15 05:26:04 PDT 2021


David Strip-4 wrote
>     that did it. Does that mean that attribute(@parent, ...) is
>     the value of the attribute for the feature for which the attribute
>     is being calculated?

Yes.



David Strip-4 wrote
>     And what does $currentfeature mean? Is it evaluated to the current
>     feature of Layer B, not A? 

Yes.

The 'filter' option of the aggregate functions is calculated with respect of
the child layer (layer B) to aggregate, so the "fields" refer to the layer B
and I think also $currentfeature should be the current feature of the layer
B, while the @parent variable refers to the feature of the parent layer
(layer A).

This could be confirmed replacing "Country_Region" (which is a field of the
child layer B) with attribute($currentfeature, 'Country_Region'), which
takes the attribute of the Country_Region field of the $currentfeature of
the layer B

aggregate( 'B','sum', "Confirmed", attribute($currentfeature,
'Country_Region') ILIKE attribute(@parent,
'SOVEREIGNT'))

and you will obtain the same results of the previous one (but with more
characters and probably more slowly)


Regards.

Andrea



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html


More information about the Qgis-user mailing list