Selection to Definition Query

11-15-2013 07:46 AM
Status: Open
Labels (1)
Occasional Contributor

Add a tool (w/ gui preferably) to get the attribute values for a set of selected features and use them in an interactive definition query dialog box which would allow the user to select which attributes to use for the querry and how to use them.  If this is set up in gui it could also be used to visually analyse for trends within the selected data.


jakubsisak‌ I can't get to the tool you linked to. It's blocked by a login prompt that doesn't like my credentials.


Hi Jakub, 

How can we get your addin ?




Is this an ArcMap Addin?

If so, do you have plans to make this for Pro as well?


A further limitation of Selections that Def Queries don't have is that many operations ignore the features/rows in "Selection from layer xxxxx" and read straight from the source table anyway. 


So I usually do this;

- Select features

- Make Layer from Selected Features

- With the new selection layer, set the symbology to Unique Values and a relevant field like id or name. (I don't use ObjectID because future edits may mess things up).

- Group all the symbols into a single group.

- Go to Labels and 'Create Label Classes from Symbology'.

- The new label class (or classes depending on what you did with your symbology) will have generated SQL.

- I then copy the SQL back to my original layer and delete the selection layer.

Once your used to it this used to be really quick in ArcMap. Still possible in Pro but requires a few more clicks.

Also ArcMap used to generate a nice SQL `IN` expression where Pro now does more verbose `AND`s.

I'll sometimes use this method to generate part of what I require. e.g. generate the SQL for a NOT statement to exclude features or combine it with some other SQL clause to further subset the set.

Some sort of tool or button would be very useful.


I also added an idea for ArcGIS Pro for this capability. It has been reviewed but still not implemented. Jakub Sisak‌ are you looking to perhaps come up with a Pro Addin too? 

My idea is here: 


IMO Esri should offer to buy Jakub's tool and make it part of official toolkit.


A tool to create a definition query that includes all selected features. Maybe using a unique identifier field like "OBJECTID". This would be a nice addition instead of having to create a new layer from selected features to see just selected features on a map.


Hi @JessieSmucker I merged the idea you just submitted with this existing idea - please add your vote to this one!  Thank you.