Adding data to Add Field in Modelbuilder

2923
6
Jump to solution
02-28-2022 12:59 PM
Labels (1)
JLSmith
New Contributor II

ArcMap 10.2

I have a closest facility model where I use a feature set to serve as a starting point(facility) and a feature class to serve as suppliers(mills). I want to calculate a total price (Mileage * Freight Rate=Cost) for material once I have the mileage from the closest facilities.  My initial idea was to add 3 fields to my routes table from the CF analysis.  I've hit a snag there because I need to be able to input the Freight Rate at some point.  And the Freight Rate changes almost weekly.  My question is how do I "insert" data after I've added the Freight Rate field?  Is there a better way to do this?

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

You bet. Are you able to test the output of the "Make Table View" (i.e. the last 4 bubbles in the model) outside of Model Builder in ArcMap? You may be able to work out whatever kink is causing the final output to be empty. The "Freight Rate" field calculator should work as long as it has the required inputs and the inputs are the right data type for the calculation.

What data does the "CF_Routes_CopyFeatures_View" have? Does it have all the variables needed to run the calculation? If not, you may need to add the table with the information as an extra input and attach it to the Field Calculation.

YouTube has some good tutorials on how to apply inline variable substitution (check this 4 minute out: https://www.youtube.com/watch?v=DKIOXEIXoGI

Cheers,

Mike

View solution in original post

0 Kudos
6 Replies
by Anonymous User
Not applicable

Hello @JLSmith ,

You might consider inline variable substitution within the input parameter for the Freight Rate value. If the Freight Rate value is changing, inline variable substitution will use whatever value is in the field at the time rather than using a fixed rate. See documentation below:

Link: Inline variable substitution - ArcGIS Pro

Link: Examples of inline model variable substitution

Cheers,

Mike

0 Kudos
JLSmith
New Contributor II

Thank you Mike.  I think example 4 in your link is the most relevant to my situation.  I just don't know how that would look or how to do it.  I don't understand how they "hook" up.  The only thing I really know is that at the point of the blue circle(see attachment) I've got a table with mileages.  I tried to create a double variable and add a calculate value tool, but when I ran it it added the field for freight rate but did not populate the field.  I do think something like example 4 would work but I just don't have any idea how to do it, i guess

Tags (1)
0 Kudos
by Anonymous User
Not applicable

You bet. Are you able to test the output of the "Make Table View" (i.e. the last 4 bubbles in the model) outside of Model Builder in ArcMap? You may be able to work out whatever kink is causing the final output to be empty. The "Freight Rate" field calculator should work as long as it has the required inputs and the inputs are the right data type for the calculation.

What data does the "CF_Routes_CopyFeatures_View" have? Does it have all the variables needed to run the calculation? If not, you may need to add the table with the information as an extra input and attach it to the Field Calculation.

YouTube has some good tutorials on how to apply inline variable substitution (check this 4 minute out: https://www.youtube.com/watch?v=DKIOXEIXoGI

Cheers,

Mike

0 Kudos
JLSmith
New Contributor II

I added add field and calculate field. I used inline variables for the calculate field. When the field is added it goes into calculate field and the inline variable populates the calculate field. The output resulted in a price per location.

 

by Anonymous User
Not applicable

@JLSmith ,

I'm glad you got it working. That's a really cool way to automate the results. Nice work!

Cheers,

Mike 

0 Kudos
GirijaKalyani
New Contributor II

Hi there, great screenshots of the work.

Just wanted to ask - did that work for rasters too? Or you were working with only feature classes?

0 Kudos