4

I know the syntax in order to fill one field with only one condition (field calculator):

case 
    when "attribut" = 'value' then value 
end 

But how to do populate automatically one field with two or three or more conditions?

I tried the following command but it does not work:

case 
    when "attribut" = 'value' and "attribut number2" = 'value' then value     
end

Could you throw light for me?

Taras
  • 32,823
  • 4
  • 66
  • 137
user35117
  • 939
  • 1
  • 7
  • 17
  • Can be relevant: https://gis.stackexchange.com/questions/301566/difference-between-quotation-marks-single-vs-double-in-qgis – Taras Nov 26 '21 at 12:05

1 Answers1

5

Your values need to have single quotes around them, one has a double quote and one has no quotes (field names need double quotes i.e. "field" and field values need single quotes i.e. 'value'):

This should work:

CASE
    WHEN "attribut" = 'value' AND "attribut number2" = 'value' THEN 'value'
END
Taras
  • 32,823
  • 4
  • 66
  • 137
artwork21
  • 35,114
  • 8
  • 66
  • 134