I'm very new at Model Builder and am trying to make a tool that selects features by attribute, with an input variable as part of the SQL query.
I have used the SQL expression MOD(Elevation,10)=0, for instance to only display elevation contour lines every 10 units out of a dataset that has a more dense spacing (say 1 unit). This works great when using the Select by Attribute tool and setting a definition query, but in this case, I need an input parameter in my model instead of a hard-coded 10 units.
Here is an example of what I'm trying to do:
When I draw my line from Supplementary Interval to Select Layer by Attribute, the entire model after Input Feature Class gets greyed out:
How can I specify the second integer parameter of the MOD() function so that I can do my selections? Any help would be appreciated.
Solved! Go to Solution.
Would something like this work for you? Right click on Select Layer by Attribute then Create Variable from Parameter then Expression. The user will be prompted to enter a value:
I would also suggest reading up on inline variable substitutions: Inline variable substitution—ArcGIS Pro | Documentation
Have you tried to run your model from the toolbox? Although it looks like the model has failed, I think it may still run once you add a value in as a parameter.
I have not tried to run the model yet. Part of the reason is that I'm also unsure how to reference the input parameter in my SQL query. Can you explain that to me? Is it simply MOD(ELEVATION,SupplementaryInterval)=0 ? I'm not real well versed in SQL either.
For some context, the part shown is the first in a series of select using a given parameter, run field calculator, rinse and repeat 3-4 times. My goal is to have attributes in a field that specify whether the contours are major, intermediate, minor, or supplementary (will make filtering contours and symbology much faster). As I have it set up now, each one of those requires a separate selection by parameter.
Would something like this work for you? Right click on Select Layer by Attribute then Create Variable from Parameter then Expression. The user will be prompted to enter a value:
I would also suggest reading up on inline variable substitutions: Inline variable substitution—ArcGIS Pro | Documentation
Yes, that did it, more or less. It prompts for the SQL query for each selection, but I can live with that for now. I'd like to read up on inline variable substitution so the various inputs are just numbers rather than expressions, but this got the job done. Thanks a bunch!