1

I want to select multiple values within a field and I am trying the following method: "xyz" in (1,2,3). I am including several values that may not exist in the attributes table, but I would like to cut and paste the formula into multiple shapes to select the values that may or may not exist in the attributes table for each shape. Since I am including values that don't exist the statement is invalid. Is there a way to enter this "blanket" formula for the shapes that would be acceptable?

closed as unclear what you're asking by PolyGeo Feb 9 '17 at 18:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Wouldn't you just need set up your query using "OR"? eg: FIELD = 'A' OR FIELD = 'B' OR FIELD = 'C' – cl3 Feb 9 '17 at 15:28
  • doesn't it work? what happens when you try it? seems to work for me – Ian Turton Feb 9 '17 at 15:41
  • That would work, but I would have to add the field name before every value and I have about 350 values. I wonder if there is a way to use "OR" without having to enter the field name 350 times? – kaya_high Feb 9 '17 at 16:43
  • check my edited answer, maybe it'll help – ami Feb 9 '17 at 17:09
  • What GIS software are you using? – PolyGeo Feb 9 '17 at 18:34
1

Solution mentioned in comment seems to be good for few values. If you have a lot of numbers try something like this:

column IN (value_1, value_2, ..., value_n)

EDIT: Maybe it's not straightforward but try that (ArcGIS):

  1. Add new field in attribute table eg. new_column

  2. use calculate field tool to calculate new column with expression (expression type - python)

Reclass(!column_with_your_values!)

and code block

values = [value_1, value_2, ..., value_n] 
def Reclass(column): 
  if column in values: 
    return 1 
  else: 
    return 0

Now you have new column with 1 if your value exists in attribute table, 0 otherwise

  1. select only that row where new_column = 1

You can combine that steps in ModelBuilder thus whole process will be faster.

  • That is what I entered, but since not all the values are in the attributes table the statement is invalid. I wonder if there is a way to use "OR" without having to enter the field name before every value? – kaya_high Feb 9 '17 at 16:45
  • check my edit in answer – ami Feb 9 '17 at 17:06
  • I was hoping for something a little simpler, but I think that will work. Thanks so much for your help! – kaya_high Feb 9 '17 at 17:30
  • As far as I can tell, the first option should work (columns in (values)). The column must exist, but the values don't have to. – phloem Feb 9 '17 at 17:35
0

Some more details would be useful to answer this question. Are you asking about ArcGIS selection by attributes or using other software? Do you have a screenshot of your attempt?

What format is your data in? Different data sources require different syntax - perhaps you're using syntax that is not appropriate for the format your data is in?

Same goes for data types, numeric values don't need quotes around them, strings do

Using the query builder (clicking on the calculator buttons and double clicking on fieldnames) should result in syntax appropriate for your data types and format.

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