1

I am new to ModelBuilder and I've been learning as I go. Almost have this model working but I've hit a snag. I have a simple Calculation that I iterate to spit out condition ratings of pipelines based on date and durability etc. This I have working fine. Problem is writing to the new field I created. I am trying to use Calculate Field inline with the iterated calculation so as it calculates it writes to my field. Problem is it updates the entire field every time it iterates over the calculation.

How can I make calculate field only write one value at a time and skip to the next cell to populate my field with satisfying pipeline condition ratings?

Problem

  • 2
    Try adding "Select" tool (System Toolbox > Analysis Tools > Extract > Select) in-line before your field calculation. Also, if possible, you might gain some efficiency using the "Iterate Feature Selection" and using the "Group By" for Install year (depending on how your conditions rating calculation is written, you might have to tweak it). Can you post more specific regarding how the "Calculate Value". Then end goal, of course, is to have a feature selection 'on' when you execute the field-calc: that way only the selected feature(s) will be written to. – Matt Goodman Aug 5 '16 at 14:27
  • The calculate value is super basic. 2016-%InstallYear% That's the entire thing. This just calculates the value that I multiply the deterioration factor by and then subtract that from our base rating of 10 to get our condition rating which is the endgame. As I said I'm kinda new so I made this as basic as possible. The entire thing consists of 5 modules 1 creates my new fields, 2 populate them the 4th does the final calc and the 5th deletes the fields I no longer want. – W11kes Aug 5 '16 at 17:42
  • Update: Still not working properly. I have changed my Iterator to Iterate Feature Selection as recommended. I tried to use the select tool but found as my iterator moved from value to value it overwrote the file and ultimately did me no good. I am currently trying to use the Select Layer By Attribute tool. I have the selections working well. The only problem is even when the correct selection is being made the Calculate Field tool still writes to every row in the field and not just the selected fields. Any suggestions? – W11kes Aug 9 '16 at 13:51
1

In the end what I was missing was the Make Feature Layer tool. I used this to make my selection with an SQL statement and to make a dummy table of only the rows I wanted to calculate. Once I did this the Calculate Field tool did exactly what I wanted. Everything else about the model stayed the same except for using the Iterate Feature Selection tool as suggested by Matt Goodman in place of the Iterate Field Value tool. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.