2

I'm trying to get the value of a feature (the area) to use as label in the print composer, but I'm not getting much success.

This is the expression I'm using in the text label in composer:

attribute(get_feature_by_id ('POLIGONAL_FNHIS2008A_8babdf78_50dc_480f_b811_0da927b7c9a5',1),'area')

The program shows me this message: No feature was found on this layer to evaluate the expression.

But the image bellow contains the information about my layer I'm referring in the expression, showing the fields and the values. What am I doing wrong?

enter image description here

0

1 Answer 1

4

You are doing nothing wrong here. The expression is correct. It just seems like, the attribute() as well as attributes() function does not work in print layout (at least in 3.16). I dont know why. I can only provide a rather poor workaround:

Instead of a textfield, add an attribute table and select your layer as datasource and remove the header as well as the frame:

enter image description here

Now click on "attributes" and open the expression builder:

enter image description here

Enter your text, concatenated with your attribute, e.g. 'The area is: ' || "test" || ' square meters':

enter image description here

Result...

enter image description here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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