I've a problem when using Select features using an expression. I've an attribute table with many features: It's a shapefile from a previous CSV table. The data are localities for water analysis, where several parameters appear. But I only want few of those locations.

What I do is:in Attribute table, I open Select by Expression, Then in Fields and Values, I select my column of interest "Parameters", and from Load Values- All Unique button, I choose the names I want to pick : alfa- hexaclorociclohexano, beta-hexaclorociclohexano, gamma-hexaclorociclohexano.

The expression I use is:

"Parametro"  =  'alfa-Hexaclorociclohexano'  +   'beta-Hexaclorociclohexano'  +  'delta-Hexaclorociclohexano'  +  'gamma-Hexaclorociclohexano'

But I can't select my values... If I just pick every value independently, i.e.: 'alfa-Hexaclorociclohexano', they are selected. Then, what my problem can be ?, should I not use the + symbol ? I also tried with the And symbol, but it's not working either. Should I try another option like the Query Builder ?

Select by Expression seemed the easier option to me but I'm not able to continue.

select by expression


2 Answers 2


There are two possibilities when you want to select several value.

The first is to use the OR operator :

"Parametro" = 'alfa-Hexaclorociclohexano' OR "Parametro" = 'beta-Hexaclorociclohexano' OR "Parametro" = 'delta-Hexaclorociclohexano' OR "Parametro" = 'gamma-Hexaclorociclohexano'

You need to repeat the field name each time (this also work if you want to use several field)

The second is to use the IN operator :

"Parametro" IN ('alfa-Hexaclorociclohexano','beta-Hexaclorociclohexano','delta-Hexaclorociclohexano','gamma-Hexaclorociclohexano')

Work only for one field but easier to read and type (of course if you need two or more field you can join several with AND or OR...)

  • Thanks for all answers. Yes, it works. I select the pollutants I want from my "Parametro" field. But the selected elements don't get highlighted in my map, I don't know why. At the end, I'd like to save the highlighted elements, to work only with them
    – prigual
    Jun 14, 2018 at 14:05
  • Don't know why it's not highlighted but if do a "save as" and check the "only selected" box you should get what you want
    – J.R
    Jun 14, 2018 at 14:15
  • 1
    Hi again. I'd like to ask a problem I'm having doing exactly the same. Same situation, same data. I'm using again this expression but the result is 0. I used both the expression with OR and with IN, but it says Output preview: 0. what can it be this time ? I think I haven't changed anything @J.R
    – prigual
    Aug 22, 2018 at 21:37

If I understand your data correctly, you should use OR, so it would read:

"Parametro" = 'alfa-Hexaclorociclohexano' OR "Parametro" = 'beta-Hexaclorociclohexano' OR "Parametro" = 'delta-Hexaclorociclohexano' OR "Parametro" = 'gamma-Hexaclorociclohexano'

That way either alpha, beta, delta or gamma gets selected. If you use AND all 4 categories have to be true.

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.