Select to view content in your preferred language

Using value from dbase table input for Field Calculation in Model Builder

1164
6
07-29-2010 10:18 AM
SheriNorton
Frequent Contributor
My model uses Summary Statistics to generate an output dbase table with a field containing a single record with the total area of the input fields of a feature class. The final step of my model uses the Calculate Field tool and needs to "read" this total area value of the dbase table in the expression.

Is there a way to assign the value this record/field in the dbase table to a variable (if so, what type?) and then use in the expression? What is the syntax for incorporating the variable?

PERCENT = (Shape_Area*100)/totalarea .... where "totalarea" is the variable with the dbase value
0 Kudos
6 Replies
BBicking1
Esri Contributor
Hi Sheri,

see if this:

PERCENT = (Shape_Area*100)/ !totalarea!

works, provided that the dBASE field name is totalarea. If not, replace it with the field's name whose value you want to use.

To access a field's value Python bookends the field name  with an exclamation mark like so:
!fieldName!

Barbara Bicking
0 Kudos
SheriNorton
Frequent Contributor
Thanks Barbara - I'll give it a shot.
0 Kudos
DanielLusher
Deactivated User
Hi Sheri,

Did this end up working?  I have a model where at one part Summary Statistics are created for a feature class, then later on I create a new field and would like to calculate the new field by taking the summary field and dividing it by a constant.  However, I cannot complete the Calculate Field tool in the model as the model does not recognize that the summary field exists.

I was hoping to know if the method worked, so I could write an expression for the Calculate Field tool using the exclimation points.

Thanks.
0 Kudos
SheriNorton
Frequent Contributor
Got a bit farther now that ArcGIS 10 is installed. I used the Get Field Value to generate a variable to hold the value (total area from the summary statistics DBF table). But when I tried running the model using this variable ("totalarea") an error occurred:
All calculated values were invalid and none of the rows have been updated.

Kind of stumped now. Does anyone know if ESRI tech support will provide assistance for basic paramter flow? I just need to figure out how to get the variable passed correctly into the Calculate Field expression. Here's what's in the expression now: ( [Shape_Area] * 100) / TotalArea
0 Kudos
SheriNorton
Frequent Contributor
Does not work because the Calculate Field expression cannot handle the variable as an input parameter (very frustrating!).

BUT - a workaround is creating a new field in the shapefile, calc all records with same value ("1"), summarizing based on the field - output dbf has a single record with the total area. Now I can use the ADDJOIN tool to create a join between the shapefile and the dbf. Once joined, I have the total area for easy use in the Calculate Field expression.
0 Kudos
DaleHoneycutt
Deactivated User
You can use variable substitution in ModelBuilder.  To see an example using Calculate Value, go to "Example 4" in the following doc: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Examples_of_inline_model_variable_subs...
0 Kudos