3

I'm trying to label my map with values taken from a different layer (meaning not my atlas coverage 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

EDIT

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

attribute(get_feature(@layer,'color_id', 
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 2 days ago
  • @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 yesterday

Your Answer

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

Browse other questions tagged or ask your own question.