A QGIS Composer atlas can be generated from a subset of the coverage layer features using the coverage layer filter control. I can filter for coverage layer features by comparing an attribute of the features to a static value, but not by comparing to a project variable (with the same value). Can this be done? What is the syntax of the expression? Is it just not possible for some reason? Is there a work-around?
I have QGIS print composer set up to generate an atlas. This uses a coverage layer 'Locations'. In the 'Locations' data is a field 'Project'. I want to print atlas pages for any feature in Locations where "Project" = '1'. Entering "Project" = '1' into the atlas coverage layer filter field works fine - I get atlas pages.
So far so good, but I'd like to be able to change the value '1', using a project variable @myvariable in its place.
Entering "Project" = @myvariable into the filter field results in no atlas pages (an error appears) even if @myvariable has the value 1. I've tried numerous changes in syntax without success.
Images to clarify question:
A Composer atlas can use select features (rather than all features) from the coverage layer - using a filter - as shown (the filter is set to "ProjectID"='1'):
Using a variable in the filter seems not to work - the error is shown here when filtering using ("ProjectID"="@currentprojectUPK):
It can be seen that the variable @currentprojectUPK has the value '1' in the list of variables as shown here:
I wondered if somehow the Composer couldn't access the variable values, but this can be used elsewhere (for example in a text box) successfully. I also wondered if there was an issue with the variable being a string not an integer, but changing it to an integer in the statement didn't help - and anyway I'm using the value successfully elsewhere.