Select to view content in your preferred language

Getting Iterate fields within model builder to work

935
2
Jump to solution
07-06-2023 02:36 PM
Labels (2)
DesislavaKsiazek
Occasional Contributor

Hi all! How can I get the fields iterator to work for my model. My model has to iterate though 58 fields in the attribute table of the layer I'm working on. For each field It has to return the total number of 0s. So far it has only done it for the first field. I have tried to use inline variable substitution - SQL expression where %Value% = 0 but it returns syntax error, so the iterator doesn't work. The fields in my attribute table are various data types.  If I ignore the field iterator the model works fine but obviously for the chosen field only. There is very little information on the use of Iterate fields option on the internet so I have mainly used these two sources:  https://pro.arcgis.com/en/pro-app/latest/tool-reference/modelbuilder-toolbox/iterate-fields.htm and https://pro.arcgis.com/en/pro-app/latest/tool-reference/modelbuilder-toolbox/examples-of-using-itera...

Capture.PNG

 

0 Kudos
1 Solution

Accepted Solutions
LindsayRaabe_FPCWA
Honored Contributor

I think you're nearly there - I tried to recreate what you're doing and here's the changes I made:

1. First of all, ensure you've limited the Iterate Fields to only use numeric field types (it will fail trying to evaluate Value = 0 if it's a text field). If you only have numeric data in your table, then this won't be an issue. 

2. Insert a String variable and enter your expression using the %Value% in-line variable there. Feed this into the Table Select as the Expression, and that should be job done. 

LindsayRaabe_FPCWA_1-1688689802590.png

 

Lindsay Raabe
GIS Officer
Forest Products Commission WA

View solution in original post

2 Replies
LindsayRaabe_FPCWA
Honored Contributor

I think you're nearly there - I tried to recreate what you're doing and here's the changes I made:

1. First of all, ensure you've limited the Iterate Fields to only use numeric field types (it will fail trying to evaluate Value = 0 if it's a text field). If you only have numeric data in your table, then this won't be an issue. 

2. Insert a String variable and enter your expression using the %Value% in-line variable there. Feed this into the Table Select as the Expression, and that should be job done. 

LindsayRaabe_FPCWA_1-1688689802590.png

 

Lindsay Raabe
GIS Officer
Forest Products Commission WA
DesislavaKsiazek
Occasional Contributor

Thank you so so very much! I can see the logic in that one. I'll give it a try and post how I got on later today/tomorrow, and mark the question as resolved  🙂