Is it possible to modify the following syntax somehow that it would be applicable in Field Calculator in QGIS? The input layer is point layer and I would like to do following calculations which I can't do in Excel due to large amount of data.

if(  "VALUE1" < 0.01, 2,
  if( AND( "VALUE1" >= 0.01, "VALUE1" < 0.1 ), 3,
    if( OR( "VALUE1" >= 0.1, "VALUE2"  >= 2 ),  4, 0 )

Any ideas?

  • Please describe more detailled what you are trying to achieve. Currently your chaining of if, and and or is absolutely wrong.
    – Erik
    Commented Mar 23, 2020 at 8:19
  • ... or right ... but not in QGIS syntax at least ...
    – Snaileater
    Commented Mar 23, 2020 at 8:20
  • @Erik Its not QGIS syntax. I would like to transform this Excel syntax to QGIS syntax for field calculator if possible?
    – Petr
    Commented Mar 23, 2020 at 8:23

2 Answers 2


You can use the CASE WHEN statement. I will give you an example, adapt it.

WHEN "VALUE1" >= 0.01 AND "VALUE1" < 0.1 THEN 3 

I applied this formula to the VALUE2 field, here is the result:

enter image description here

  • Thanks, your method worked.
    – Petr
    Commented Mar 23, 2020 at 14:15

Just offset the logical operators and petr's syntax is right (imho)

if("VALUE1"<0.01,2,if("VALUE1">=0.01 AND "VALUE1"<0.1,3,if("VALUE1" >=0.1 OR "VALUE2">=2,4,0)))
  • Thank you, in the end my expression turned out to be close to correct one.
    – Petr
    Commented Mar 23, 2020 at 14:16
  • Yep you're right ... where does your syntax come from ?
    – Snaileater
    Commented Mar 23, 2020 at 15:28
  • What do you mean? Its from Ecxel and has been edited by someone here on this thread to this form. My original idea was to do it in Excel, however I have over 1.200.000 points with more columns and Ecel could not handle the data. After the calculalation was done I used rasterize tool to create a raster with values 2,3, and 4.
    – Petr
    Commented Mar 23, 2020 at 16:43

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.