I'm using QGIS 3.10.

I'm trying to label my map with values taken from a different layer (meaning not my atlas coverage layer), which is intersecting the atlas cover layer.

This layer named "Colorisé" has a categorized style using the field "color_id". I want my legend items to be labelled with the field "idprop".

I have tried using this expression (1), which returns the featured items not individually but as a list :

aggregate('Colorisé', 'concatenate_unique', "idprop", intersects($geometry,@atlas_geometry), ',', "idprop")

And I have tried using the expression below (2), which returns the first value it can find (I guess) and applies it to all my legend items :

attribute(get_feature('Colorisé', 'color_id', intersects($geometry, @atlas_geometry)), 'idprop')

Can you guys tell me if I'm anywhere close to getting the desired results ?

You can find below an excerpt from the table of attributes of the layer "Colorisé" and an image summing up the situation.

enter image description here

enter image description here


Using this expression seems to be working in the preview, but the labels end up being empty :

attribute($currentfeature, 'color_id')),'idprop')
  • What version of qgis is? What is the link between the "atlas layer" and "colorisé" ? Where do you use your expression ?Please add some detail. – Vincent Dulout Jan 15 at 9:02
  • @VincentDulout I'm using the latest stable version. There is no link between the layers per say, except for the layer's geometry "Colorisé" intersecting the atlas' geometry. I run the expressions through the string builder available in the print composer under the legend properties. – stanichou Jan 15 at 18:44

I thought about your problematic and may be your way is not the correct point of view, or mine isn't too.

What about adding the value "idprop" from your layer "colorised" into your atlas layer coverage? In the perspective of managing your database is more consistent : your don't multiply the source of data and so you can use it in different ways.

You didn't specify the quality of your layers, but i assumed there are polygons.

So you can use this algorithm "join attributes by location" or the next one Join attributes by location (summary).


I actually got a working solution from another forum.

Here is the code :

aggregate(@layer, 'concatenate', "idprop", filter:="color_id"=@symbol_label AND intersects($geometry, @atlas_geometry), concatenator:=', ')

Hopefully this helps people who have had a similar issue as mine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.