3

I'm in QGIS layouts trying to make a custom grid coordinate format but get the error:

No feature was found on this layer to evaluate the expression.

This error does not appear if I have a single substr() function but when I add a second it errors.

concat(substr(@grid_number, -5, 2),
       ",",
       substr(@grid_number, -3)
       )

enter image description here

3
  • OP should add information about what is the aim of the expression and what the variable @grid_number represents.
    – Babel
    Sep 10, 2021 at 20:13
  • @Babel @grid_number is a built in expression in printlayout representing the current lat/lon value of the added grid.
    – MrXsquared
    Sep 10, 2021 at 20:26
  • @MrXsquared - OK, I see, a context variable.
    – Babel
    Sep 10, 2021 at 20:31

1 Answer 1

5

Change your double quotes of "," into single quotes ',', since it is not related to a fieldname but is meant to represent a string value:

concat(substr(@grid_number, -5, 2),
       ',',
       substr(@grid_number, -3)
       )

The error No feature was found on this layer to evaluate the expression. is caused by QGIS trying to lookup for a field named , but there is no feature which this expression is evaluated against and therefore also no fieldname named like that.

1
  • Thank you. No matter the programming language I always get confused about double and single quotes. Wish QGIS had better docs for their language.
    – jake9wi
    Sep 12, 2021 at 23:44

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.