2

I want to do some calculations based on a column which has the same name as the layout name (Graugans in this example).

To have less typing work, I thought about using the layout name as variable. But it doesn't work, the expression dialog shows: No feature was found on this layer to evaluate the expression.

But when I type the name Graugans instead of @layout_name, it works...What am I doing wrong?

Here is the code:

This doesn't work:

aggregate( 'bgrbauswertung22_4f14ac5b_b4c2_4f88_a29b_16379028da2e', 'sum',  "@layout_name")

This works:

aggregate( 'bgrbauswertung22_4f14ac5b_b4c2_4f88_a29b_16379028da2e', 'sum',  "Graugans")

@layout_name gives back Graugans

0

1 Answer 1

2

A double quote references a field in a layer. Here it searches for a field called @layout_name, which is not present in the layer.

You need to use eval() function to evaluate the variable @layout_name first:

aggregate('mylayer','sum',eval(@layout_name))
0

Your Answer

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

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