Hello GIS friends,
I'm using a ModelBuilder to select Multiple values from a layer and it is not working. It only works when I select a single value. What am I doing wrong please.
Select Layer By Attribute expression window:
Model: Please do not worry about the grey portion. That part is working fine. Instead, the part that is not grey is not working.
Geoprocessing:
In the window below marked in red, if I only put one value (SPB) then it will select, however if I put multiple values (SPB, EAB, etc.) as shown below it will not select.
I've added a variable to the model that would allow me to put Multiple values.
Please help me.
Thank you,
Abi
Hello!
Did you have any joy in finding a solution?
I have managed to use the Select Layer By Attributes tool in Model Builder using the AND operator to query a string and a numeric field, which I think is what you want to do.
I have assumed that your variable parameter YearParameter is numeric. Would that be correct?
My model does what you want to do.
It assumes the Gender variable parameter is querying a string attribute field (this would be the equivalent of your TypeParameter ) and so the variable parameter datatype is set to String.
The Pupils variable parameter is querying a numeric attribute field (this would be the equivalent of your YearParameter) and so the variable parameter datatype is set to Long.
Notice my SQL Expression:
The Gender parameter is surrounded by %% signs and speech marks as you would expect, as it is querying the GENDER attribute field in my Schools dataset.
The Pupils parameter is surrounded by %% but it IS NOT enclosed by speech marks as querying a numeric field. I think when you placed speech marks around your "%YearParameter%" you turned it into a string...?
So.... remove the speech marks around your YearParameter in the SQL Expression for the Select Layer By Attribute tool and change the data type of the YearParameter variable parameter to Long?
I hope this helps.
ed
Hey Ed,
Lol, it would've been a joy had I found a solution. Thank you for posting your response. I really appreciate it.
I tried your syntax. Both my parameters are string, and the SQL Expression is not working. I do not know what I'm doing wrong.
Please advise.
Abi
Are you able to find out anything, Ed?