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 was just wondering if anybody knows of a way to write an expression to make all my numeric values in my labels positive.

I want to do 1234 cal BC 23 cal AD for example, as a label.

My data is - 1234 (being BC) and 23 for AD.

any ideas?

share|improve this question
    
For quick draw time, add/calculate a new field of all positive values with the designated BC or AD already in it. –  ccn Jan 28 '13 at 21:56
add comment

2 Answers

On the 'Labels' page of the layer properties box (the one that opens when you double click a layer) you can use the Method drop down to define classes with different types of labels.

Then you can pick the features that have negative values and format their labels to be positive, then set up a second class to do the non-negative ones.

This tutorial is much more detailed and goes through the whole process of creating label classes.

share|improve this answer
add comment

Go to the Labels tab on Layer Properties, click Expression.... On the Label Expression dialog

  1. check the Advanced checkbox
  2. paste the code below into the Expression (update [DATE] to whatever your field name is)
  3. set the Parser to python

.

def FindLabel ( [DATE] ):
  v = int([DATE])
  if v < 0:
    return "{} BC".format(abs(v))
  else:
    return [DATE] + " AD"

Then draw the Labels.

share|improve this answer
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.