[GIS] QGIS field-calculator replace function

field-calculatorqgis

I've got a Shapefile containing contourlines which I would like to style differently according to their value. For that reason I created a field named "100s" where I would like to give values from 0=25m-lines, 1=100m-lines and 2=500m-lines.
For doing that I tried the "replace" function with this syntax:

NAME="4600" OR NAME="4700" OR NAME="4800"  replace('NULL','NULL','1')

but QGIS gives the following error: "syntax error, unexpected FUNCTION, expecting $end". When I then set "$end, the error message is the same. Any suggestions how to resolve that?
Thanks in advance,
Ralf

Best Answer

It's giving you that error because it's the wrong syntax. The OR and AND keywords return true or false. The replace function is for strings so you don't really need it here. What you are looking for is the case expression:

CASE WHEN NAME="4600" OR NAME="4700" OR NAME="4800" THEN 1 END

Note: You need to be running the dev build of QGIS to get that function