Hi i'm struggling to finalize a model i'm making. from my final results i want to extract the lowest (minimum) value and save it.
i'm using an "iterate feature classes" tool so i need to be able to add %name% into the expression so it will find the lowest value for each of the files that goes into the tool
The column Elev_Diff is the column i want the minimum value from
the name of the file will be a variable (from iterator) called %name%
any ideas?
Solved! Go to Solution.
I believe that the issues being faces are related to the geodatabase referenced in G (7_Match_DTM_Assessment.gdb) and used for the FC to FC in B. This is currently a File Geodatabase (.gdb) and needs to be a Personal Geodatabase with a .mdb extension.
1. Use summary statistics tool, statistics field will be your Elev_Diff and statistics will be MIN, don't use any case field. This will create a table with one row, containing your minimum Elev_Diff.
2. Then Iterate field value of this table to get your name parameter.
Finding the minimum value:
This may be difficult to do as shapefiles don't fully support subqueries (See link here). However, if the data were stored within a Personal Geodatabase (MDB) this could be done using the following query:
Elev_Diff in (select MIN(Elev_Diff) from <featureclass>)
Exporting a file with the name of its input:
I would suggest adding another tool to the end of the model, Copy Features, to copy the selected features to a new file.
Thanks for both your suggestions
Christian;
your method looks the more promising of the two. I've converted the data into a geodatabase but i can't seem to get the query to validate. i'm sure its something obvious i'm doing wrong.
[Elev_Diff] in (select MIN([Elev_Diff]) from %name%)
Riyas;
your method would work but would require more processing to create points and bring data back into the tables so i'd be keen to avoid this method if i can.
Hi Jamie,
Here is how I set up my model. I put all of the shapefiles into a Personal Geodatabase, then used the iterate tool to loop through them and create a new feature class using the following expression: [Area_SqFt] in (select MIN( [Area_SqFt]) from %Name%)
No problem. Do you get the error when running the model or verifying the SQL expression? If it happens during the verify, this would be expected because the verification does not substitute the value of the inline variable when evaluating an expression. When the tool runs, the value of the inline variable is substituted in the expression and the results are created based on the substituted values. (See link here)
Hi Christian,
Still having trouble getting this to work.
the data is now held in a geodatabase but i'm sill getting errors (see attached) when the model runs
i've used the query using the feature class to feature class tool and select tool in model builder with the same error outcome
Can you send a picture of your model and the settings of the "Name” variable?