I have a shapefile with a field called "Name". The name field contains many hundred columns of City, Lake, River, County. I want to add a value in another field for each of the entries in "Name". Like, all records of City will get the value 10, all records of Lake get the value 7 and so on.

Is there an easy way to do this?

  • 1
    I would create a lookup table and then use Join Fields. – PolyGeo Dec 4 '15 at 12:58
  • 1
    I think @PolyGeo 's suggestion would be the easiest way. Comment if you want some assistance with that. – jbchurchill Dec 4 '15 at 13:41
  • Create new field for value, after that sort names in field and then select same record, choose selected items (bottom of attribute table) finally assign value to same name in value filed by field calculator, this would be easy if names diversity is a little – Predator X Dec 4 '15 at 17:36

The lookup table suggestion by PolyGeo is probably the best way to go if there are a lot of different values in the Name field, especially if you don't know what those values may be. Start by creating a Summary Statistics table of the Name field to get a table with all of the unique values in the field. Then add your second field and populate it. Then use the JoinField tool or do a standard join and then export the shapefile layer to create a new shapefile with the field.

If you already know the set of possible values in the Name field and there are around 30 or fewer different values you can use the Field Calculator as userBZ suggested. If there are 7 or fewer known values in the Name field, the If Then ElseIf Else syntax works in VB Script. However, if there are more than 7 different values you must use the Select Case syntax for VB Script. Python has similar If Elif Else syntax and Switch Case syntax structures. The Select Case syntax processes more efficiently, but it is limited to literal value comparisons and not other kinds of logical comparisons like <, >, etc.


You can try an IF THEN ELSE structure in the Field calculator.

See the ArcGIS Samples for an example.

Since I don't know exactly what you data looks like, I can;t give you a more precize answer. What do you mean by a field having columns? A field in your attribute table typically is a column.

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.