Model Builder Select By Attributes

5894
5
Jump to solution
05-08-2013 06:52 AM
MarkYoung
Occasional Contributor
Hi,
I have a feature class where I wish to select various values from a field. Once those values are selected I wish to populate another field with a corresponding certain value using calculate field. How can I simply select attributes in a feature class without exporting to another feature class?
Thanks
Mark
0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor
Hi,
Solved this myself in the end if anyone may be interested..
Maybe not the slickest of models as no iterators involved but it works.

Select by attributes (analysis) set output to use in memory results
Input results to Calculate field tool

Repeat the select and calculate for the various group selections and finally merge all the calculate field results into a new feature class.

Mark


You did not need to do any Select by Attribute if you had created a single Field Calculator expression that used a Select Case structure.  The Output field would be your URL field.

Parser: VB Script

Use Codeblock: checked

Codeblock:
If IsNull([Route_ID] Then   Output = [URL_Field] ' Don't change URL field value Else   Select Case [Route_ID]     Case "Mon1", "Mon2", "Mon3"       Output = "The URL for Monday"     Case "Tue1", "Tue2", Tue3"       Output = "The URL for Tuesday"     ' Etc.     Case Else       Output = [URL_Field] ' Don't change URL field value   End Select End If


Expression: Output

View solution in original post

0 Kudos
5 Replies
RobertBorchert
Frequent Contributor III
If your only doing it the one time don't bother with model builder simply so it with select by attributes.

However, when you perform it in model builder it does not export a new feature class.  simply to the select by attributes.  it will make your selection then perform the calculate function on the appropriate attributes.

Hi,
I have a feature class where I wish to select various values from a field. Once those values are selected I wish to populate another field with a corresponding certain value using calculate field. How can I simply select attributes in a feature class without exporting to another feature class?
Thanks
Mark
0 Kudos
MarkYoung
Occasional Contributor
Hi,
I have a number of different values which consist of (for example), Mon1 Mon2 Mon3 these relate to collection routes which have their own collection calendars, the calendars can be linked to via a URL which I would like to populate a field with.

On that note, if there is a way to iterate through the other sets of values like Tues1 Tues2 Tues3 etc etc and populate those subsequent groups with their corresponding URL that would be great. I tried to look at iterate by row selection but I can't see how to build in a query.

What I have tried to do so far is load the feature class to model builder, input to the select (analysis) tool specifying my selection Mon1 Mon2 Mon 3 then link that result to a calculate field tool where the URL is entered in the expression field.

It runs but when I look at my feature class there are no results in the website field.

Thanks
Mark
0 Kudos
MarkYoung
Occasional Contributor
Hi,
Solved this myself in the end if anyone may be interested..
Maybe not the slickest of models as no iterators involved but it works.

Select by attributes (analysis) set output to use in memory results
Input results to Calculate field tool

Repeat the select and calculate for the various group selections and finally merge all the calculate field results into a new feature class.

Mark
0 Kudos
RichardFairhurst
MVP Honored Contributor
Hi,
Solved this myself in the end if anyone may be interested..
Maybe not the slickest of models as no iterators involved but it works.

Select by attributes (analysis) set output to use in memory results
Input results to Calculate field tool

Repeat the select and calculate for the various group selections and finally merge all the calculate field results into a new feature class.

Mark


You did not need to do any Select by Attribute if you had created a single Field Calculator expression that used a Select Case structure.  The Output field would be your URL field.

Parser: VB Script

Use Codeblock: checked

Codeblock:
If IsNull([Route_ID] Then   Output = [URL_Field] ' Don't change URL field value Else   Select Case [Route_ID]     Case "Mon1", "Mon2", "Mon3"       Output = "The URL for Monday"     Case "Tue1", "Tue2", Tue3"       Output = "The URL for Tuesday"     ' Etc.     Case Else       Output = [URL_Field] ' Don't change URL field value   End Select End If


Expression: Output
0 Kudos
MarkYoung
Occasional Contributor
Thank you for your reply - I will try and implement the field calculator for the additional up and coming rounds..
Mark
0 Kudos