Iterate Field Values, not iterating, returning Value = 1

4476
6
Jump to solution
03-01-2016 09:13 AM
TylerSchwartz2
Occasional Contributor II

Hello my GIS colleagues,

I am having a problem with the Iterate Field Values tool within Model Builder.

What I am trying to do:

Iterate through a field within a feature class, and then Select By Attribute based on the unique value that the field iterator returns.  So within my Markets layer, I have a field called "NAME" and I want my iterator to select each unique value under NAME and do a select by attribute (which I will later use to do a select by location on a points layer of my patients, but this is largely irrelevant to my problem). I am using an inline variable based on the value that the field iterator returns to do my select by attribute.

The problem:

Iterate Field Values returns a "1" for "Value", and the model only runs once (the iterator should have the model cycle at least 10 or so times for the 10 unique values in the field "NAME").

I suspect my problem is where I have the iterator setup in my model, basically, the iterator is not running *frist* and just using the default value of 1.

I have attached a screenshot of my model.  I have seen this problem come up numerous times on geonet but there is no concrete solution listed.  I KNOW others have had this problem.  Thank you for your help!

0 Kudos
1 Solution

Accepted Solutions
TylerSchwartz2
Occasional Contributor II

Thank you.

Somehow I was able to get this to work. After a bunch of trial and error, and fixing a of the other tools in my model resulted in this working eventually.  I am attaching my updated model, for anyone else who had this problem.

Thank you for your help Xander.

View solution in original post

6 Replies
XanderBakker
Esri Esteemed Contributor

The "Value" should connect to the Select by Attribute tool. See: Examples of using iterators in ModelBuilder—Help | ArcGIS for Desktop

TylerSchwartz2
Occasional Contributor II

Can you clarify?  I can either connect Value as a precondition, or as an expression. Connecting as expression doesnt work because I need my expression to read NAME='%Value%', and when I connect as an expression it changes the expression to be: Value (and when I force it to be NAME='%Value%' it disconnects the line).

When adding Value as a precondition, the rest of model does not run.  My output is attached...

XanderBakker
Esri Esteemed Contributor

I just created a simple model as a test, that allows the user to select a featureclass and a field and the output workspace. It will run over the unique values in the selected field and create an output featureclass for each unique value in the field:

The Iterate Field is not connected to the Featureclass to Featureclass conversion. The Iterate Field Values is configured like this.

And the FC to FC conversion like this:

It loops through the values and creates a featureclass as expected...

TylerSchwartz2
Occasional Contributor II

Thank you.

Somehow I was able to get this to work. After a bunch of trial and error, and fixing a of the other tools in my model resulted in this working eventually.  I am attaching my updated model, for anyone else who had this problem.

Thank you for your help Xander.

View solution in original post

ChrisWoodward1
New Contributor III

Tyler/Xander,

I've not personally used iterate much but I have long realized this tool could be very useful. If you'll permit me, I'd like to re-state what the overall purpose of both iterate models is to ensure I'm understanding them properly. Please chime in to correct me in my attempts to understand these great and varied examples.

In Xander's example, this model creates a single feature class for each unique name from the input feature class called "Selected Feature Class". I can see this ability to be very useful, especially using the name (%Value%) of the selected field for the output FC name.

In Tyler's example,  (if I'm understanding it correctly) the purpose is to export a summary *.CSV of do some calculations on several values. That model iterates on the Name field of the input "Markets_Merged" feature class and literates a selection based upon that resultant value. Next, that model performs a spatial selection on "Newpatients_112015" (a point feature class, I'm assuming) that are within the selected market name. When the resulting new patients are selected that are within the iterated market name, the market name (%Value% from the iterate function) is calculated to the newly added "Market" field name on the new patients feature class. Lastly in Tyler's model, summary statistics are run to create a CSV table with a count of the site and market fields (presumably of a count of new patients per site and per market) with the iterated market name in the file output CSV title.

Thank you both for this opportunity to learn more about iterate functions!

0 Kudos
TylerSchwartz2
Occasional Contributor II

Hi Chris,

You got it!  This is exactly what my model was designed to do. In fact, I am using the output of my model (csv) which I will then copy/paste into a different excel file in order to automatically populate some charts and graphs for a monthly report we need to generate.

I look at an iterator as a model builder version of a "for loop" in coding.  Any time you need your model to cycle through a list of features, attributes, etc you can usually find an iterator type that meets your specific needs.

Now my next challenge is to merge all of my csv's into one table within model builder.  I guess I will need to learn Python now in order to write a script for that!

Regards