Problem with Field Calculator

1259
19
05-09-2022 12:12 PM
aam
by
Occasional Contributor

I am using ArcGIS Pro, I have a Feature Class along with standalone tables, the content of tables need to be brought into the Feature Class.

The Table contains over 6000 records and I use Definition query to filter out the records that I need to bring in. I do a join based on the Primary ID and then using the Field Calculator to populate the records from the joined table. However when I run the Field Calculator, the records that I are suppose to be hiding (filtered out) are being populated.

Has anyone experienced this before, how can I overcome this?

0 Kudos
19 Replies
RhettZufelt
MVP Frequent Contributor

Screenshot of the calculator tool?

Is it possible you have the same attribute name in the feature class as well as the joined table?

If so, make sure you scroll down far enough to pick the joinedtablename.FieldName (not just FieldName) so it knows to pull the data from that table/field.

R_

0 Kudos
jcarlson
MVP Esteemed Contributor

To prevent populating the other features, you can:

  1. Select by Attributes first, run the calculation on the selection. Or,
  2. Include a statement in your calculation that checks the attribute value, and leaves it alone if it is not one of the target rows

What language are you using? If you use Arcade, there's no reason to perform a join ahead of time.

var x = $feature.['primary_id_field']

var lyr = FeatureSetByName(
    $map,
    'the other layer',
    ['primary_id_field', 'the_other_attribute_you_want'],
    false
)

var feat = First(Filter(
    lyr,
    `primary_id_field = ${x}`
))

return feat['the_other_attribute_you_want']
- Josh Carlson
Kendall County GIS
0 Kudos
aam
by
Occasional Contributor

Here is the video of what I am doing

0 Kudos
jcarlson
MVP Esteemed Contributor

Something must be going funny in between the join and the calculation. Thank you for sharing the video, it's much easier to see what's going on.

Personally, I would use Arcade to make absolutely sure that the other table is being filtered the way you intend it to be. You can get the matching feature based on the ID and filter the layer at the same time.

var x = $feature.['primary_id_field']

var lyr = FeatureSetByName(
    $map,
    'the other layer',
    [
        'primary_id_field',
        'the_other_attribute_you_want',
        'attribute_in_your_definition_query'
    ],
    false
)

var feat = First(Filter(
    lyr,
    `primary_id_field = ${x} AND attribute_in_your_definition_query = some_value`
))

return feat['the_other_attribute_you_want']
- Josh Carlson
Kendall County GIS
0 Kudos
aam
by
Occasional Contributor

I've never used Arcade. Curious to know where exactly do I write the code?

0 Kudos
RhettZufelt
MVP Frequent Contributor
BryndaHatch
Esri Contributor

The Field Calculator will either work on a selected set of records or, if nothing is selected, it will work on all of the records.  Perhaps, after setting your definition query to hide the records you don't want, select the remaining records before running the Field Calculator.  

0 Kudos
aam
by
Occasional Contributor

Here is the video of what I am doing

0 Kudos
RhettZufelt
MVP Frequent Contributor

Are the tables geodatabase tables or Excel?

What if you don't put a definition query on the lookup table, but put the join on the Feature class, show only matching data (when establishing the join), then put the definition query on the feature class only.

R_