Select to view content in your preferred language

Question about Select by Attribute and Field Calculator

296
5
4 weeks ago
EGardner7
New Contributor II

When I first select by attribute and then use python in field calculator am I only editing the fields for the attributes I selected for or is it still editing everything? Thanks!

0 Kudos
5 Replies
PTW
by
New Contributor II

After selecting by attribute, right click the layer and go to Selection -> Make Layer from Selected Features. This will create a temporary layer and you may want to right click and go to Data-> Export Features and you can save the subset layer. Then use the new saved layer and you will only edit the desired fields.

0 Kudos
EGardner7
New Contributor II

So that means when I have the show selected records button pressed and then I enter something into field calculator it will still edit things that aren't selected? 

0 Kudos
BlakeTerhune
MVP Regular Contributor

After making a selection, you can use the CalculateField Python command (or geoprocessing tool) to edit the fields of only the selected records. However, make sure your input for it is the layer with the selection and not a generic path to the feature class in the geodatabase. In the latter case, it won't have a selection and it will field calc all records.

You can also run the tool with an undo option in case there is unexpected behavior.

PTW
by
New Contributor II

@BlakeTerhunewas more thorough with their response!

The solution I suggested above should guarantee only the desired fields will be updated.

0 Kudos
JimCousins
MVP Regular Contributor

The field calculator will only apply to the selected records.

If you are at all concerned, run your field calculations in an edit session, where you have the option to "undo".

0 Kudos