1

I have a attribute table (xlsx sheet imported with the plugin 'spreadsheet layer'). For example, it contain only 15 lines

enter image description here

I have filtred the data with this request that return 6 lines (correct result) :

"VALID" != '70' AND "MILIEU" IN ( 'Entrées de grotte' , 'Grottes et cavernes obscures' , 'Cavité artificielle avec influences humaines' ) AND "STRUCTURE" NOT IN ('tunnel','égoûts, canalisation')

enter image description here
enter image description here

Now, if I try to extact data with the same request in the processing modeler, I don't obtain the same result. All data with a NULL value in the field 'Structure' have been filtered. Any idea?

I don't understand why the first code works with the query and not with the extract processing?

enter image description here enter image description here

1 Answer 1

1

Try adding the following to your expression:

OR "STRUCTURE" = NULL

So your expression would look like:

"VALID" != '70' AND
"MILIEU" IN ('Entrées de grotte', 'Grottes et cavernes obscures', 'Cavité artificielle avec influences humaines') AND 
("STRUCTURE" NOT IN ('tunnel','égoûts, canalisation') OR 
"STRUCTURE" IS NULL)

It seems NULL values are not taken into account when using the IN operator.

5
  • Thank @Joseph for your reply! Unfortunately, this only works partially. with the example, it return me 7 lines ('Cavités art.[..]', NULL, 70). By following your example, I could make a complete query with the 'OR', but in my case, I have to filter an excel file on many fields and the query becomes very long. I don't understand why it works with the query and not with the extract processing. Commented Jan 21, 2019 at 11:01
  • @Christophe - Try "STRUCTURE" = NULL instead. I guess it's the way the processing tool is scripted.
    – Joseph
    Commented Jan 21, 2019 at 11:10
  • With "STRUCTURE" = NULL (instean 'IS NULL') it return me only 2 lines. All data with a NULL value have been filtered Commented Jan 21, 2019 at 11:18
  • 1
    Your solution works with parentheses and IS : "VALID" != '70' AND "MILIEU" IN ( 'Entrées de grotte' , 'Grottes et cavernes obscures' , 'Cavité artificielle avec influences humaines' ) AND ("STRUCTURE" NOT IN ('tunnel','égoûts, canalisation') OR "STRUCTURE" IS NULL) Commented Jan 21, 2019 at 13:14
  • @Christophe - Nice one! Glad you got it to work for your example :)
    – Joseph
    Commented Jan 22, 2019 at 10:04

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.