5

I am trying to build a field calculator expression to merge two columns into one. I am looking for the word that makes it a range.

Example: I have 2 columns in elevation, From and To. I want to make them like "4100 - 4200" where I add the hyphen. How do I do that ?

table showing data being worked with

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 11, 2011 at 16:21
0

1 Answer 1

15

You will want to concatenate the two fields together.

To do this in ArcMap you can use the VB Script function "&". So using your example, the calculation would be

[FROM] & "-" & [TO]

You could also use Python syntax, in which case your code would be:

str(!FROM!) + "-" + str(!TO!)

With Python you want to be sure to enclose the fields in the string function -- str()--, so that Python knows you are trying to concatenate two strings together, and not do a mathematical computation.

answered Oct 11, 2011 at 16:31
1
  • just for fun, you could also use the format string python operator: "%s - %s" % (str(!FROM!), str(!TO!)), which in this case is more complicated than the above, but is easier if you want to more extended concatenations, e.g. "Min %s - to - %s Max" % (str(!FROM!), str(!TO!)) Commented Oct 11, 2011 at 22:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.