I have a shape file with point numbers for individual ID's. I would like to select point numbers divisible by a number, and if the remainder is 0 then I would like to label that point.

I have tried about 1000 different combinations using the Modulo operator, but I continue to get an "Expression is invalid" error.

Pseudocode for the expression is as follows:

When % ("Point_Number", 7) = 0
Then "Point_Number"
  • 2
    What software are you using? – Dan C Sep 24 '14 at 16:27
  • There was a similar question recently in which the OP wanted to select contours with at an interval of 50 m. The modulo function was used. The answer might be of use to you for your application: gis.stackexchange.com/questions/114012/… – WhiteboxDev Sep 24 '14 at 16:31
  • If it's ArcGIS that you're using, then based on Edixon's answer to the question I linked to, I'd say your expression should read: MOD("Point_Number", 7)=0, where Point_Number is your attribute field ID (notice that it's longer than 10 characters) and 7 is the interval that you want to select, i.e. select every 7th feature. – WhiteboxDev Sep 24 '14 at 16:43
  • Sorry, I forgot to mention I am using QGIS. I get this to work all of the time in other software packages, but I guess I am not familiar enough with the syntax necessary in the Labeling Expression Builder to do this properly – jbgramm Sep 24 '14 at 18:16

Here's an expression that should work:

case when "Point_Number" % 7 = 0 then "Point_Number" end
  • That is excellent! Thank You Very Much! I tried just about everything I could think of based upon the syntax from other packages that I have used. I simply made it too complicated. Thank you again! – jbgramm Sep 24 '14 at 22:32

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.