I'm not a QGIS power user but I've been using it for simple things for quite a while. I just updated from QGIS 2.14 to 2.18 yesterday in order to be able to edit field names. I'm now having some problems with filtering using multiple bracketed expressions that I don't think I had before, but it had been a little while.

For example, I'm trying to filter this parcel data shapefile by land use codes (which are an integer64 field, so they are numerical). The shapefile has 399212 records. When I apply the filter

("15USE">=1000 and "15USE"<=2900) or ("15USE" >= 7000 and "15USE"<=7900) or ("15USE"=8901)

shown below, it does not filter out any records:

Filter applied

Strangely, the exact same expression, copied and pasted into the Select by Expression Builder, selects a subset of the records (about 200,000 or so):

Successful selection by same filter

For what it's worth, the "isselected" function does not appear to serve as a workaround - I've never gotten it to work, despite reading about it on here:

"Isselected" function undefined

What am I missing here? Did the filtering syntax change? I know that queries/filters have always been less sophisticated than selection expressions, but this is weird. Or am I (more likely) doing something wrong?

Mac OS X Yosemite; 2011 MacBook Pro, 8GB upgraded memory, 500 GB upgraded SSD; QGIS: 2.18

1 Answer 1


As you can see there are two SQL query dialogs:

  1. Provider based dialog
  2. QGIS own implementations expression dialog

The first dialog transfer SQL query string directly to provider (i.e. database). In this dialog you can use specific syntax for your database or other datasource. I don't understand why your simple query ("15USE">=1000 and "15USE"<=2900) or ("15USE" >= 7000 and "15USE"<=7900) or ("15USE"=8901) not executed properly (need the test data to reproduce, but first of all I don't see the field 15USE on first screenshot).

The second dialog is QGIS specific and has additional features like some python-like functions and keywords. The behaviour of SQL query in this dialog may vary from first dialog.

  • Ah I understand, I've read that there are two different dialogs. I still don't understand why it fails to filter (the "15USE" field is there, just wasn't scrolled down to it), as I've used other expressions with multiple parentheses to filter in this same project (filtering strings, in most cases). In the end I save a new shapefile with the selection, but it would be nice not to have to do that. Is it something about how integers are handled, compared to strings?
    – KHT
    Commented Jul 14, 2018 at 16:50
  • Your expression looks fine, so needed the test shapefile to reproduce this behaviour. Commented Jul 14, 2018 at 19:59

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.