I'm new at this, so please bare with me. I was recently asked if I could create a map showing tax parcel color coded in to code classes (ie - > 50,000, 50,000-100,000, etc) and then have the assessment value labeled on each parcel as well. Our assessment values are in represented into the 100 place (ie - ($)120,200, ($)15,800, ($)267,800, etc.), however they have asked if I can that the labels be 120K, 16K, 268K and so forth. (essentially rounding the numbers to the nears 1000. I have found where I can pick how many significant digits should appear, but anything less than 100,000 rounds to the 100 not to the nearest 1000. (ie - $15,800 remains this as opposed to being rounded to 16,000).
Is this something that is possible to achieve with labeling or is it possible by using the field calculator? Thanks your any help you can provide me.
Solved! Go to Solution.
Dynamic labeling using Python should do it for you. Set the label parser to Python and use an expression like this:
"{}K".format(int(round([VALFIELD] / 1000.0)))
You can test this kind of thing at the Python prompt:
>>> "{}K".format(int(round(120800 / 1000.0))) '121K'
You can do it both ways. Dynamic labeling with scripts usually comes with a performance hit since it has to do the job with every feature with every pan, zoom etc. If you create a field and calculate it, you would only run the script once and label on that field.
Are your values text entries or numbers?
If they are integers you can use this to calculate the new text field using the python parser
str(value / 1000) + 'K'
If they are floats
str(int(value) / 1000) + 'K'
Replace 'value' in the above script with '!your_field_name!
Keep in mind this doesn't round, it truncates. So 259,900 would show up as 259K instead of 260K.
In the field calculator change the parser to python and use the following formula:
int(round( !A_Value! , -3)) / 1000
This will give you the rounded value in thousands.
Edit - you will need to replace the !A_Value! with your own field name.
Dynamic labeling using Python should do it for you. Set the label parser to Python and use an expression like this:
"{}K".format(int(round([VALFIELD] / 1000.0)))
You can test this kind of thing at the Python prompt:
>>> "{}K".format(int(round(120800 / 1000.0))) '121K'
That's much better than mine.
Note that the first formula has an extra closing parenthesis after the field placeholder [VALFIELD] that will result in an error:
"{}K".format(int(round([VALFIELD]) / 1000.0)))
Parsing error SyntaxError: invalid syntax (line 1)
Remove the extra closing parenthesis and it works great.
As long as you are not labelling a crazy number of features I would go for the dynamic labelling as you don't need to update calculated fields as your data changes.