# How to use field calculator to create a field based on another?

I have a field called `RTS` (Range,Township,Section(typically looks like `153320` with each two digits representing)). Would like to transpose to Township Range Section. Example from above would look like `331520`.

Is there any VB or Python that would work?

For labeling, I used the following, which worked by the way.

``````Function FindLabel ( [RTS] )
FindLabel = mid([RTS],3,2) & mid([RTS],1,2) & mid([RTS],5,2)
End Function
``````
• Have you looked at gis.stackexchange.com/questions/15038/…? – HimBromBeere Apr 21 '16 at 14:44
• But when you only want to transpose in the fieldcalculator you already have your code to put in. Just without the Function stuff... So probably i understand you wrong... – Matte Apr 21 '16 at 14:53
• Python !Name![-2:]+!Name![2:4]+ !Name![:2] providing it is a string – FelixIP Apr 22 '16 at 3:45

There are many ways to achieve this. For example using the field-calculator.

1. Create your three new Fields (e.g. using Toolbox)
2. FieldCalculator (e.g. Python syntax)

Field `Township`:

``````= ['RTS'][2:3]
``````

Field `Range`:

``````= ['RTS'][0:1]
``````

Field `Section`:

``````= ['RTS'][4:5]
``````

Alternatively the following arcpy-code should work:

``````cursor = arcpy.UpdateCursor(myTable)
for row in cursor:
value = row.get_value('RTS')
row.set_Value('Township', value[2:3])
row.set_Value('Range', value[0:1])
row.set_Value('Section', value[4:5])

cursor.updateRow(row)
``````

EDIT: If you only want to reorder your value use this:

``````cursor = arcpy.UpdateCursor(myTable)
for row in cursor:
value = row.get_value('RTS')
row.set_Value('RTS', value[2:3] + value[0:1] + value[4:5])

cursor.updateRow(row)
``````
• Actually I'm wanting to have a single field, just in a different order. Transpose 153320 to 331520. Thanks for chiming in BTW – S Tucker Apr 21 '16 at 15:09
• @STucker see my edit – HimBromBeere Apr 21 '16 at 21:05

Just modify what you have for your labeling a little bit, for calculating it should be: `mid( [RTS] ,3,2) + mid( [RTS] ,1,2) + mid( [RTS] ,5,2)`

• I guess for performance it´s better to cache the value of `[RTS]` before using it. Thus you won´t hit the database three-times but only once. – HimBromBeere Apr 21 '16 at 21:07

Like others have suggested I think field calculator is the way to go on this one. I would just create a new field called TRS using a similar expression to the one you created the labels with.