How can I include 'All' in a Variable Picklist

1115
13
10-28-2019 12:10 PM
AyokunleAdebisi
New Contributor III

I am building a tool using model builder in ArcGIS pro. I will like the user to be to select all in my variable pick-list;for instance i want the user to select all location (polygon).

0 Kudos
13 Replies
AyokunleAdebisi
New Contributor III

Please I need a urgent response or the question is not clear enough? I can explain further.

0 Kudos
by Anonymous User
Not applicable

A little more detail about what your model is doing could be helpful, but one way you could go about this is using a "Logical" operator:

to test the input value. If the value equals a value of your choice, representing 'all' (for example "All Sites"), then that branch would use a selection expression that selects all sites.  If not, the expression will select whatever site is selected from the pick list.

Here is a very quick example:

and then the expression would use the variable if the user selected something other than the "all" value, for example:

AyokunleAdebisi
New Contributor III

Thanks for the reply,my model wants to know the population of birds in a single location which I have done, then I want to further let user to know the number of birds in all location,  for instance what is the population of a bird in all location. Now in the dropdown list (sitename), where you have single location, I want to include picklist "ALL" to select all location.

0 Kudos
by Anonymous User
Not applicable

If you are manually supplying the values for the pick list using the parameter properties, then you can add a value such as "ALL", for example:

and then if the user chooses that option, use a branch of the model to execute a SQL statement that selects all records. For example, this expression would select all sites:

You can test whether the user chooses that option with a logical operator, which I see you already have in your model.

If you are familiar with Python, you might consider that as another option. Typically I find Python easier to work with when a model starts using lots of conditional logic.

0 Kudos
AyokunleAdebisi
New Contributor III

Thanks for the response I will test this, And get back.

0 Kudos
AyokunleAdebisi
New Contributor III

sorry it did not work..I guess I don't understand what you explained. Can you explain further.. For instance I am building a tools that will select all polygon using modelbuilder..How can I include ' all' option for user. for example, i am building this from the scratch:

0 Kudos
by Anonymous User
Not applicable

Sure, here is another example that I think is a bit closer to your situation.

This model simply selects a country from a polygon layer and calculates summary statistics using the selection:

I added a "Country" variable and made it a model parameter.

The key thing is then to go into the model properties (right-click the model in the toolbox and click Properties) and enter the values that you want to appear in the pick list. I entered in some country names as well as "ALL COUNTRIES":

This creates the pick list when the tool is opened in the Geoprocessing pane:

In the model, we can then test whether the user has selected ALL COUNTRIES from the pick list:

If True, that means that the user selected "ALL COUNTRIES", and we use the Select by Attribute tool to select all polygons:

If False, that means that they selected a country name, and then we use the name of the country in the SQL expression, using the Country variable:

Preconditions are used in the model to determine which Select by Attribute tool gets executed.

I attached the example toolbox here, hopefully it will be useful.

AyokunleAdebisi
New Contributor III

Thanks for your help. One more question..what is the "Values" doing there...is it a shapefile of country aside the country parameter or what, and is it also included in condition if value.

0 Kudos
by Anonymous User
Not applicable

The "Values" variable contains the value to test against to see if the condition is true or false. You can test against multiple values, but in this case, we just care if the user chose the "ALL COUNTRIES" value or not. 

So the string that you type in to this variable should be exactly the same as the one you type in to the parameter properties when you are specifying the values that will appear in the drop-down. You can type your value (for example, "ALL COUNTRIES") directly into the "If Value Is" tool, and it will create this "Values" variable for you (at least it did in my case).