Generating a multivalue choice list

Prerequisite Reading
Generating a choice list from a field

This blog is an extension of the blog Generating a choice list from a field, explaining:

How to create a MULTIVALUE parameter choice list from an input feature class/table automatically. In this example, multiple input parameters from a choice list are then iterated through.  The model can be easily extended to carry out numerous analysis that require user selected input parameters.

Download the data from here.

Understanding the model:

  1. Download an example script tool from here.
  2. Add the script tool to the model.
  3. Expose the input parameters (input feature class, field, value) of the script tool in the model.
  4. Make the input parameters model parameter.
  5. Use as described in the example below:

In the following example, the user can define an input feature class (e.g.Bird Locations) and a field (e.g. Type) to generate a value list, from the model tool dialog. The value list parameter is then populated with a choice list of all the unique values in the field. This list is a multivalue parameter i.e. you can select multiple values from the drop down list.

The output of the script tool is the multivalue with all the selected value (e.g. American Coot, Black Scoter, Canada Goose and Gadwall). In the model provided, this multivalue output is then connected to the Multivalue Iterator as input in the sub-model. Learn more about model within a model/sub-model.

The tool then iterates over each value (e.g. American Coot, Black Scoter, Canada Goose and Gadwall). The output of this iterator (Values variable) is then input to the Select tool as an inline variable, in the expression, to select features (Type” = ‘%Value%’). Learn more about inline variable substitution.

The Calculate Value tool is used to remove spaces in the selected values (e.g. American Coot changes to AmericanCoot (no space)) using the .replace Python function.

The output of the Calculate Value tool is then used as inline variable in the output of the Select tool (e.g. C:ScratchScratch.gdb%Name%).

The Collect Value tool is used to collect the output from all the iterations. The output of the Collect Value tool is made a model parameter so that when the sub-model is added to the main model, the output of model parameter becomes a variable in the model.

To run the iterator and the Calculate Value tool before the Select tool two preconditions are created:

  1. From the output of the iterator to the Select tool.
  2. From the output of the Calculate tool to the Select tool.


  • To iterate the values with other tools for your project, add your tools in the sub model either in place of the Select tool or connected to the output of Select.
  • If you do not want to iterate put all your tools in the main model.
  • If Choose Multiple Field Value is not the first tool in your model and is connected to other tools such as Add Field tool upstream, make sure to run the tools up to the Choose Field Values tool once and validate such that the tool sees the newly added field in the drop down list of its parameter. The tool is useful when the input field list is known and you can choose the values of the field before you execute the tool.

**************IMPORTANT NOTE**************

  • If you change the field value after selecting values from the filter list the codes generates a new unique list of values for the new field, and checks if the old selected values exist in the new list. If true, it retains the selection else removes the selection. This behavior differs a little if the tool is used in ModelBuilder and you make the tool parameter – Value a variables in the model. In such a case, if the field value is changed after the selection and the value does not exist in the new list an empty check is left at the end of the new list. You must uncheck the last value or unselect all the values and then reselect the desired values. The designed behavior in ModelBuilder is not to erase the user modified values unless the user makes a conscious choice.

Understanding the tool
Prerequisite reading – Read more about the tool and the validation code for the tool from here.

To make this script tool parameters a multivalue parameter, the script tool property for the Value and Output value parameters have been changed as shown below:

The script tool validation code can be accessed by right clicking the script tool > selecting Properties > Validation tab > and clicking the Edit button. This opens the validation code in the Python editor for better viewing. The code has added comments explaining the code on each line.

This entry was posted in Analysis & Geoprocessing and tagged , , . Bookmark the permalink.

Leave a Reply


  1. zhouyaxin8 says:

    Hi shitijmehta,

    I was trying to run this model but run into an error as below. Would you please help me solve the problem?

    ” ERROR
    updateParameters Execution Error: Runtime error Traceback (most recent call last): File “C:\Documents and Settings\zhou_y\Desktop\Multipl\”, line 4, in File “C:\Documents and Settings\zhou_y\Desktop\Multipl\”, line 31, in updateParameters File “c:\program files\arcgis\desktop10.2\arcpy\arcpy\”, line 1031, in Frequency raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000824: The tool is not licensed. Failed to execute (Frequency).”

    I was using ArcGIS 10.2 for desktop version And I have checked the expensions as listed: Spatial Analyst, Schematics, Publisher, Network Analyst, Geostatistical Analyst, and Arc Scan.

  2. hazelton_glenn says:

    this error has nothing to do with extensions. it is the level of arcmap that is the issue. it must be ‘Advanced’ and not ‘Basic’.

  3. landvest says:

    Is there any reason the model displayed in this blog post does not match the models contained in the script you are instructed to download?

    • landvest says:

      Ok, I see now, it requires modification. However, based on what i’m reading here, you need Advanced to get the validation to work properly, correct? I tried to remove the validation in a new script, but then the script isn’t able to derive the value list it seems.

      • shitijmehta says:

        yes, it requires advanced as it uses the Frequency tool. You could try using the summary statistic tool instead which is available at all levels.

        • justingleeson1 says:

          Hi there,
          Hope this post makes it to you. It’s been a year since the last update.

          This is an interesting post and looks like it could be a solution for a problem I have. Do you think this could be used (with modifications) as a means of controlling user input to an Iterate Raster process?
          See post here for what I am trying to do:

          I’d appreciate your thoughts before I get properly stuck into this.



        • hydie03 says:

          Did anyone ever get this to work with the Summary Statistic Tool instead of the Frequency tool? I wanted to publish my model to ArcGIS Server, but I only have the standard license, not Advanced. Thanks…

          • gstavish521 says:

            I have found a work-around to select multiple values from a feature class/table that does not require an advanced license. However, populating a check box list capable of selecting multiple values is my snag. The script shitijmehta wrote for the “Generating a choice list from a field” ( can populate a check box list from a feature class or table (if you modify the script parameters for “value” and “output value” to have MultiValue = “yes” and the “output value” derived from “values”), but the script only allows the user to select one of the values from the list. Does anybody know how to modify the script to allow multiple value selections? At any rate, a work-around for this exists too. You can set a “Filter” for “Value List” ( and manually enter the values for your check box list (this is not ideal if you have 1,000 values you need to populate). But if you manage to get a check box list that can populate multiple values, you need to modify the output expression to remove the semi-colons and add two apostrophes. You can do this by connecting the script’s Output Value as a precondition to the Calculate Value tool and using the expression: “%Output Value%”.replace(“;”, “‘,’”). Then have this output connect to Select tool as a precondition, with the expression: “yourvaluename” IN (‘%output_value%’). This will modify the script’s output from (‘value1;value2;value3;value4′) to (‘value1′,’value2′,’value3′,’value4′) and the expression can be populated into a new table.

  4. michaelides says:

    Hello. I have been killing myself to make this tool to work with my data but unfortunately keeps crushing.
    I have an advanced license but this doesn’t seem to solve the problem.
    I tried to make it work with the sample’s data changing the field that the multi-value would be available. For example i edited both the model and sub-model, making the field “Year” as the one that the user will select values from. In all my tries the model didn’t change the values (always showing the “Type” values), but the frequency table did summarize the “year” values. Then Arcmap crashes. I do mention that working the model with the sample’s data, without any editing works fine.

    • shitijmehta says:

      Sent you an email. Send me your data and which version of ArcGIS are you using?

      • michaelides says:

        Dear Mrs Mehta, thanks for the reply here but I can’t see the email that you sent me because i only have access on that email account at work. I just entered the blog to check if someone answered. Well on Monday 08/08/16, i will try to send you a part of my data. I have Arcgis 10.3.1 with windows 10.
        Also i don’t know if this is possible but can i have some walk through on how to edit the model and sub-model to read my data (with so many frustrated attempts on my part i think the instructions in this blog might be needing more detail – no intention to insult).
        Also where in the model is the tool of the frequency table? I just want to set it not be added in the TOC at all.
        Thanks again.

  5. shiulipervin says:

    now I have different Problem. I want to draw stack profile for raster layers and I want the user could chhose there colors of cooresponding raster interactively from tools drop down list. For that How can I create filter list inside script and user can chose multiple value.