7

I have an attribute table of contours at intervals of 10m but I wish to label the layer at intervals of 50m. My method was to create a new field with an expression which would copy the entries in the parent field (PROP_VALUE) whose value would be a multiple of 50. i.e 50,100,150,200 etc leaving the entry empty (NULL) if not a multiple of 50.

I got somewhere with the CASE expression but QGIS wouldn't let me repeat the expression for 100m, 150, and 200m. I suppose I could update the existing field but there must be a simple/faster way.

enter image description here

  • 4
    Not sure exactly for qgis as I don't use it, but there should be a modulo command e.g. mod(field, 50) for multiples of 50 etc – Midavalo Apr 3 '17 at 13:37
8

You only need to include CASE at the beginning and END at the end of your expression. So it should read:

CASE 
WHEN "PROP_VALUE" IS 50 THEN '50' 
WHEN "PROP_VALUE" IS 100 THEN '100' 
...
END

As @Midavalo mentioned, you could also use the modulo operator:

CASE WHEN "PROP_VALUE" % 50 = 0 THEN "PROP_VALUE" END
  • @JamesB - Most welcome and don't worry about it! You should see some of the first questions I asked here ;) – Joseph Apr 5 '17 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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