3

enter image description here

I working with ModelBuilder and I have two summary statistics tools, with 'case fields' that have multiple sum values, I want to use these sum values from one table and divide the sum values from the other table to get percentages,I have added a field in one table to store the percentages. I am using Iterate Field Values tool to get the output values that I can input into Calculate field to get the percentage, it works but only for the first record, obviously because it is only getting one value from the summary tables, I tried Collect values tool to get multiple values, but I get an error 000539, I using the code from this discussion: How to extract multiple values out of a table in ModelBuilder

Calculate Value

I have more than than 2 values so I guess List and not index is required.

The whole model runs I get all the results, except the error with collect Value tool. ModelHere is snap shot of the model, I will separate the iterator tool and add it as submodel once it works.

Here are the input tables and I want to calculate PctCtyPop using calculate field by dividing the 2 SUM_POPULATION, calculate field it giving me the right value for the 1st record 5505/20202 but for the second instead of getting 118774/131506, it is giving some thing else.

  • Could you add a screenshot of the input tables and how you want them to turn out? – BERA Mar 16 '17 at 18:05
  • @BERA I have added the 2 tables that I am getting from the two summary statistics and are being used to get PctCtyPop field. – JSSR Mar 16 '17 at 20:19
  • You talk about "sorting out the iterator" when you get the model fixed, well I suspect that is YOUR problem.Remember EVERYTHING in the model runs as many times as the iterator loops. So your selections that create the summary table will be executed X number of times. I suspect that is NOT what you intended. The Collects tool is being misused, that is for creating a list in a sub-model and passing that list out into a master model, you currently have everything is a single master model. The logic of this model is fundamentally flawed and you need to separate out into sub-models. – Hornbydd Mar 16 '17 at 22:49
1

I did not need to use Collect Values tool after all, instead I used a spatial join and did a Sum for County population, so that dropped one summary statistics from my previous workflow, I then used Add Join to combine the tables, which made it easier to use Calculate Field tool and I got the results I was looking for. Here is model with final changes and the resulting output table with county percentages, within the metropolitan area.Final model

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.