I know you can use wildcards for fields like so (in the Field Calculator):

case when "column" ILIKE '%example%' then 1
else 0

Can you do something similar for the column headers themselves?

I ask this because I'm joining several layers (using the Joins properties) and it would make it easier for me to edit one set of filters instead of editing several filters since the column names will have to include the joined layer name.

I'm using QGIS 2.2.

2 Answers 2


With the introduction of the Function Editor back in QGIS 2.8, it is possible to iterate through the field names and perform some sort of analysis:

from qgis.core import *
from qgis.gui import *

@qgsfunction(args='auto', group='Custom')
def fields(feature, parent):
    layer = qgis.utils.iface.activeLayer()
    field_names = [field.name() for field in layer.fields()]
    for name in field_names:
        if "some_name" in name:
            # Do something

Sorry. Wildcards are for use in strings, and unfortunately the double quotes around a column name don't mean that it's a string. Column names are "identifiers", which I think are basically object names, but I'm no expert. That doesn't mean that there is no way to do what you're asking, but it won't be happening in field calculator.

  • Thanks Zack, I understand about columns/fields being "identifiers", would be nice if they could somehow include it. I will accept this answer for now anyway :)
    – Joseph
    Jan 29, 2015 at 11:00

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.