Select to view content in your preferred language

How can you pass a variable to a SQL Expression for a Select by Attribute in Modelbuilder

918
2
Jump to solution
09-28-2023 04:23 PM
JohnDavidson
New Contributor III

Working to create a script which iterates over a set of CSV files and then joins to a ZIP file. One that is completed, it goes through to Select by Attribute to ensure we are looking only true values and not null.

JohnDavidson_0-1695943002754.png

I have the model written and it works well on the first pass, but when it comes to the next file it fails because the Select Layer by Attribute is looking for the previous filename. How can I pass the filename as a variable? Is this possible?

I have referenced the below article without any luck in having it work either.

https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/modelbuilder/inline-variable-su...

Any help to get this working would be greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
JohnDavidson
New Contributor III

I am not sure why I didn't think of this sooner. So I was able to get the %Variable% working as it should, but then I couldn't get the second half working such as '.csv.REV_SUB_TOTAL'

I added it as its own Variable called %String% and then changed my SQL statement to %Name%%String% IS NOT NULL and it worked!

View solution in original post

0 Kudos
2 Replies
JohnDavidson
New Contributor III

I am not sure why I didn't think of this sooner. So I was able to get the %Variable% working as it should, but then I couldn't get the second half working such as '.csv.REV_SUB_TOTAL'

I added it as its own Variable called %String% and then changed my SQL statement to %Name%%String% IS NOT NULL and it worked!

0 Kudos
AbiDhakal
Occasional Contributor III

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.

Model:
AbiDhakal_5-1722620330495.png

Select Layer By Attribute expression window:

AbiDhakal_4-1722620282794.png

Parameter:

AbiDhakal_6-1722620375850.png

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. 

AbiDhakal_2-1722620170964.png

I've added a variable to the model that would allow me to put Multiple values.

AbiDhakal_3-1722620171043.png

Please help me.

Thank you,
Abi

 

0 Kudos