I'm working with QGIS 3.16 Hannover and this should be very straightforward but I'm unable to solve it.
I'm producing different maps, filtering the features of a layer. In the composer manager, I'm trying to create an automated legend title using the Expression String Builder that includes the value of an attribute of the first feature of that filtered layer. All my attempts with the commands attribute()
and get_feature()
or get_feature_by_id()
have failed.
Best Answer
You can use the aggregate function for that:
Aggregates all values form field
my_fieldname
of the layermy_layer
into an array and witharray_get
you can get the value at position 0