Skip to main content
deleted 35 characters in body
Source Link
Taras
  • 36k
  • 7
  • 77
  • 153

For what is worth, I found this question in 2025. UsingUsing QGIS version 3.34, I used the function eval()eval() to "convert" the variable to a string so it can be processed as a query.

In my case I wanted to be able to change the field name used in a query for a rule based renderer, because not always the structure of the data that I was using was the same.

So for a query like:

TIPO in ('22400000','22440000')

TIPO in ('22400000','22440000') 

where I could have the field named LAYER or CODICE, I defined a project variable:

@project_layer_field

@project_layer_field 

set as TIPO, and used in the filter

eval( @project_layer_field ) in ('22400000','22440000')

eval( @project_layer_field ) in ('22400000','22440000') 

and it worked as expected.

For what is worth, I found this question in 2025. Using version 3.34, I used the function eval() to "convert" the variable to a string so it can be processed as a query.

In my case I wanted to be able to change the field name used in a query for a rule based renderer, because not always the structure of the data that I was using was the same.

So for a query like

TIPO in ('22400000','22440000')

where I could have the field named LAYER or CODICE, I defined a project variable

@project_layer_field

set as TIPO, and used in the filter

eval( @project_layer_field ) in ('22400000','22440000')

and it worked as expected.

Using QGIS version 3.34, I used the function eval() to "convert" the variable to a string so it can be processed as a query.

In my case I wanted to be able to change the field name used in a query for a rule based renderer, because not always the structure of the data that I was using was the same.

So for a query like:

TIPO in ('22400000','22440000') 

where I could have the field named LAYER or CODICE, I defined a project variable:

@project_layer_field 

set as TIPO, and used in the filter

eval( @project_layer_field ) in ('22400000','22440000') 

and it worked as expected.

Source Link

For what is worth, I found this question in 2025. Using version 3.34, I used the function eval() to "convert" the variable to a string so it can be processed as a query.

In my case I wanted to be able to change the field name used in a query for a rule based renderer, because not always the structure of the data that I was using was the same.

So for a query like

TIPO in ('22400000','22440000')

where I could have the field named LAYER or CODICE, I defined a project variable

@project_layer_field

set as TIPO, and used in the filter

eval( @project_layer_field ) in ('22400000','22440000')

and it worked as expected.