1

I am essentially trying to do what is listed in this question:

Renaming field via ModelBuilder?

So I am trying to use the Add field > Calculate Field > Delete Field method listed but the problem is my field names keep changing as they are based on an ID (%Value%) in my model so I can't just do

[NewFiled]=[OldField]

Instead I need to do something like

[NewField]= [OldField %Value% +3 ]

However I'm not sure if this is possible to do a calculation within a field name.

Below is the long version:

I have a model (see below) that creates a number of different shapefiles that are named "School_%Value%" where %Value% can be a number from 1 to 797 (I only have 121 shapefiles but their values fall within that range).

enter image description here

Because of the join that occurs half way through the model all the field names get renamed, and because the ID is numeric each field gets iterated so if the Shapefile "School_1" had columns Name, Date, Address, they become School_1, School_2, School_3. If my shapefile "School_100" had the same three columns they will be School_100, School_102, School_103.

I at least know the column I need to change is always the last one, so the name will always be %Value% + 3, but I'm not sure how to do arithmetic in a field value in the calculate field tool.

3
  • With the environment setting "Maintain fully qualified field names" turned off, the field names should not be renamed in the join. I think..
    – Bera
    Commented Mar 24, 2018 at 7:07
  • I tried this, but in the model properties it seems like fully qualified field names are turned off by default, but turning them on and off doesn't seem to do anything. Commented Mar 24, 2018 at 15:50
  • Why not explicitly name the frequency output table and join table used in the join? That way the table and field names will be consistent. Just make sure your overwrite output is set to true Commented Mar 24, 2018 at 19:18

0

Your Answer

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