Hello, i'm using Modelbuilder too analyse a point feture class.
Goal is to iterate different sql expressions out of a tabel to select various features of the point feature class.
Question: is there a possibility to name the output of the selection referring the sql expression out of the iterator.
using the variable %Value% doesnt work because there a spaces in the sql expression (example: YEARS BETWEEN 0 AND 9)
is there a possibility to use for example a different column for the naming?
Currently used iterator: Iterate Field Values
Thanks for the help
Solved! Go to Solution.
You can use another Calculate Value tool to insert spaces as follows
"%SQL Expr%".replace(" ", "_")
this would convert your expression to the string:
YEARS_BETWEEN_0_AND_9
and use the created variable in your output name instead of %n%:
You may want to try the For iterator with Calculate Value tool to generate each sql expression, for example:
Calculate Value expression:
"YEARS BETWEEN {} AND {}".format(%n% * 10, ((%n% + 1) * 10) - 1)
With the For set to be 0 to 2 by 1 you'd get these expressions on each iteration, which you then would pipe into a Select Layer by Attributes or Select tool:
YEARS BETWEEN 0 AND 9
YEARS BETWEEN 10 AND 19
YEARS BETWEEN 20 AND 29
SQL reference for query expressions used in ArcGIS—ArcGIS Pro | ArcGIS Desktop
Examples of using iterators in ModelBuilder—Tools | ArcGIS Desktop
Thank you,
this is working, but not bringing the solution to the main problem.
Even with this way you can't name the output of the Select tool after an iterated input. Like Tool: Select --> Name of the output feature class: "OutputSelect_%Output_Value%" (not working because of the spaces in "YEARS BETWEEN 0 AND 9"). Using the %Value% out of the Iterator `for` doesnt make it any better because then there is only writen "0", "1" an so on... (This can be reached by putting n into the output name of the select tool: "OutputSelect_%n%")
So is there a possibility to tell the iterater so output another column of the iteration tabel?
Thanks for all the help
You can use another Calculate Value tool to insert spaces as follows
"%SQL Expr%".replace(" ", "_")
this would convert your expression to the string:
YEARS_BETWEEN_0_AND_9
and use the created variable in your output name instead of %n%:
Thank you so much! That helped a lot
Regards