Select by Attribute then Calculate field based on selection

1385
2
Jump to solution
05-31-2012 06:35 AM
StephanieMacuga
New Contributor III
Hi!

I'm attempting to rebuild a VBA macro that I have using Model Builder but ran into a stumbling block. 

I have a dateset that I need to calculate the next inspection date for each feature, but that inspection date will vary based on what type of feature it is.  Feature type "1" is inspected again in 365 days, feature type "2" is inspected in 180 days, and feature type "3" is inspected in 120 days.  Ideally I simply select the features that match a type, calculate the next inspection date, then run the process again for types 2 and 3 all within the same shapefile.  I'd prefer not to select the features and export each type into a new table (thus resulting in 3 new tables when they need to all be in the same table). 

Any ideas on how I can accomplish this in Model Builder?

Thanks!!
Stephanie
0 Kudos
1 Solution

Accepted Solutions
JonathanQuinn
Esri Frequent Contributor
It sounds as if you'll just want to use the Select by Attribute tool three times in your model to select for the three different feature types.  After each individual selection, you'll want to use the Calculate Field tool to calculate whatever values you need to for the inspection date.  If you have any selected features in a table, any operation you run will only run on those selected features.  The default selection method of NEW_SELECTION will make sure that each successive selection will overwrite the previous one.  A rough model showing the process is included below.  Is that something that makes sense for your workflow, or are you looking for something else?

[ATTACH=CONFIG]14805[/ATTACH]

View solution in original post

0 Kudos
2 Replies
JonathanQuinn
Esri Frequent Contributor
It sounds as if you'll just want to use the Select by Attribute tool three times in your model to select for the three different feature types.  After each individual selection, you'll want to use the Calculate Field tool to calculate whatever values you need to for the inspection date.  If you have any selected features in a table, any operation you run will only run on those selected features.  The default selection method of NEW_SELECTION will make sure that each successive selection will overwrite the previous one.  A rough model showing the process is included below.  Is that something that makes sense for your workflow, or are you looking for something else?

[ATTACH=CONFIG]14805[/ATTACH]
0 Kudos
StephanieMacuga
New Contributor III
Thank you!

That did work very well for me.  I had run some geoprocessing events on the dataset prior, so I did have to run "Make Feature Layer" before I could start the selections/calculate field processing.  In the end though, it works beautifully. Thanks for your help :)
0 Kudos