4

Is it possible to use a variable in a layer filter? For example, I'd like to have

"STATE" = @current_state

to only display the features within a certain state. Trying to do this gives me an SQL syntax error.

7

Variables are used in QGIS expressions and can not be used for the feature filter functionality of the layer.

Please also see the answer to QGIS query syntax differs between attribute table and feature filter for detailed information about the difference.

What you could do instead for visualisation purpose is to setup a rule based renderer or use data defined symbology to make use of QGIS expressions with full variable support.

  • Could you use such variables in the Advanced Filter (Expression) option in the Attribute Table? – Joseph Sep 30 '16 at 10:19
  • 1
    I didn't check but I don't see a reason why not. – Matthias Kuhn Sep 30 '16 at 10:20

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.