Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
add comment

1 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

share|improve this answer
2  
CASE WHEN expressions seem to be working with 1.8. as well. Either that or I am using a devbuild in disguise... –  GR_ Dec 10 '12 at 9:32
    
They might work in 1.8 I lost track when they were added. –  Nathan W Dec 10 '12 at 9:46
    
Hello Nathan,thank you very much! I tried this solution after installing the latest version but infact I didn't get that function. Since I'm running a MAC I looked for the dev build at kynchaos but I wasn't shure which one to choose ... could you please provide a link to the working version? Thanks again, –  Ralf Glaser Dec 10 '12 at 10:37
    
I just checked.. CASE WHEN works on 1.8 under Mac. –  GR_ Dec 10 '12 at 11:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.