I have an output from a sub model that iterates through feature classes, each with a row count. The row counts are passed to a collect values, which is a model parameter and is used outside the sub model.

How can i use simple code in a "calculate value" tool to get the maximum value from this list of numbers. I wish to then use this as a precondition to subsequent analysis so that if the sub model does not produce results then the subsequent analysis will not run.

This is similar to Exporting data from Collect Values output in ArcGIS ModelBuilder? that wished to use the actual list of numbers. The answer suggested an export to .csv file.

I only need to use a simple output so that I can use it as a pre condition on subsequent analysis. I have tried to calculate the Max(list), but it has not worked.

  • You might find this post helpful.
    – Paul
    Commented Aug 14, 2013 at 15:16
  • Thanks. I checked again, unfortunately the "summary statistics" and the "Get Field Value" cannot be linked to the output of "collect values" from an iterator, which is why i was trying to find a way by using the "calculate value" tool.
    – user21053
    Commented Aug 14, 2013 at 15:29

2 Answers 2


OK you have a model that is collecting values (of type long) and its a parameter. This is a sub model to the master model. In the master model connect your collection of values as a precondition to a Calculate Value tool. These collected values are called "Output Values".

In your Calculate Values tool:


summe("%Output Values%")

Code Block:

import string
def summe(s):
  l = string.split(s,";")
  max = -1
  for i in l:
    if i > max:
      max = i
  return max

Data type:


This approach is taking advantage of the fact that your collected values are "MultiValues" which are semicolon separated.

Example model finding the max value in a multivalue list

  • i have just check this and it works brilliantly. thanks very much. Jonathan
    – user21053
    Commented Aug 14, 2013 at 16:02
  • So from '8;22', is '8' is the largest string, but 22 is the largest number.
    – Mike T
    Commented Nov 12, 2013 at 22:28
  • This can be done in one expression max([int(x) for x in !Output_Values!.split(';')]) (no code block)
    – Mike T
    Commented Nov 12, 2013 at 22:31

Sounds like you've got a three step process: a) Values from each iteration b) Max value from all iterations c) use the max value to calculate additional steps for each iteration.

A workaround might be to use 'Append' to join the outputs of each of the iterations to a single file. Then you can use 'Max' on that file.

Alternately, use a 'merge' on the collected values, and then use summary statistics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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