Issues with Calculate Field tool in ModelBuilder

1445
3
04-13-2021 08:58 AM
Labels (1)
EmilyHale1
New Contributor

I'm working with ModelBuilder within ArcGIS Pro 2.7.2. The model I'm creating shouldn't be too complicated, but I seem to be having issues... 

I start by joining two tables of interest, in this case, Species Range Data with Land Cover for two different time periods. Then, I am using the Calculate Field tool to A) Add a field, for example "PctCHNG_Sttl" which doesn't currently exist in the table, and B) Calculate that new field by subtracting Sttl_Time2-Sttl_Time1. However, when I open my final output, it seems like these new fields are being added as type "TEXT" rather than "DOUBLE", even though they are calculating correctly... Am I missing something?

Just for reference:

EmilyHale1_0-1618329416720.png

 

Tags (1)
0 Kudos
3 Replies
Robert_LeClair
Esri Notable Contributor

In the Calculate Field GP tool in the model, when you add a new field in the GP tool parameter, you'll be prompted to select the FIELD TYPE.  Change the Field Type to DOUBLE.  It defaults to TEXT so this explains what you're seeing in the result.

0 Kudos
EmilyHale1
New Contributor

Hey, thanks for the response. I see what you're saying. However, as you can see in the screencap I had attached, rather than using the Add Field tool (which would prompt me with FIELD TYPE) I was hoping to skip a step, use the Calculate Field tool, and for Field Name I would create a new field name and do the calc. However, when I choose to create a New Field Name, I don't seem to see an option to adjust field type... Does that make sense, or have I missed your point? 

0 Kudos
Robert_LeClair
Esri Notable Contributor

You're welcome!  The Calculate Field GP tool will allow you to skip the "Add Field" GP tool step.  I wonder, because it's in a model, when you add the field name in the model, it "skips" the Field Type parameter and defaults to TEXT.  What you could do is make both the Field Name (New or Existing Field) and Field Type as model parameters - right click and select Model Parameter for each.  Then when you run the model, it prompts you for the FIELD NAME and FIELD TYPE.  Then you can click Run and it should populate correctly.