方法

新しいフィールドを計算し、ArcGIS Pro の属性テーブルの 2 つのフィールドで一致する値を特定する

Last Published: October 1, 2025

サマリー

In some cases, when analyzing different fields for the same features in an attribute table, it is necessary to identify matching values in two fields. A new field can be created and calculated to reflect the noted comparison between the two fields. This article provides the instructions to do so in ArcGIS Pro. In this example, the comparison is made between the SOURCE and SOURCE_ED fields. The matching values are identified and populated in the new field, SOURCE_MATCH.

手順

  1. Add a new field to the attribute table.
    1. In the table, click Add Field The Add Field icon to add a new field to the attribute table.. The Fields view opens.
    2. In the Fields view, specify a name for the new field in the Field Name column. In this example, the new field is SOURCE_MATCH.
    3. Double-click the Alias column of the new field, and specify an alias for it. In this example, the alias is SOURCE_MATCH.
    4. Double-click the Data Type column of the new field, and select Text from the drop-down menu.
    5. On the top ribbon, on the Fields tab, click Save The Save button to save the newly created field in the attribute table..
  2. Calculate the new field to identify matching values in the two fields.
    1. Open the table, right-click the new field, and click Calculate Field. The Calculate Field window opens.
    2. In the Calculate Field window, for Input Table, select the table containing the fields to compare and the new field.
    3. For Field Name (Existing or New), select the new field created in Step 1. In this example, the field is SOURCE_MATCH.
    4. For Expression Type, select Python 3.
    5. Copy the following expression, and paste it in the Expression box. Replace !field1! and !field2! by double-clicking the two fields in the Fields list. In this example, the two fields are SOURCE and SOURCE_ED.
calc(!field1!,!field2!)
  1. Copy the following script, and paste it in the Code Block box:
def calc(field1 , field2):
    if field1 == field2 :
        return 'Yes'
    else:
        return 'No' 
Replace field1 and field2 with the two fields to be compared. In this example, field1 and field2 are replaced with SOURCE and SOURCE_ED respectively.
def calc(SOURCE , SOURCE_ED):
    if SOURCE == SOURCE_ED :
        return 'Yes'
    else:
        return 'No' 
  1. Click the Verify The Verify icon to verfiy the expression in the Calculate Field before running the tool. icon to validate the expression.
  2. Click Run.
The Calculate Field window containing the parameters and expression to calculate the new field with matching values from two fields in the attribute table.

The following image shows the new field containing the identified matching values from two existing fields in the attribute table.

The attribute table containing the new field containing the matching values from the two fields.

記事 ID: 000025230

新しい問題や一般的な問題に対する通知とソリューションの受け取り

新しい AI チャットボットから、要約された回答とビデオソリューションを入手してください。

Esri Support アプリのダウンロード

関連情報

このトピックについてさらに調べる

ArcGIS エキスパートのサポートを受ける

テクニカル サポートへのお問い合わせ

Esri Support アプリのダウンロード

ダウンロード オプションに移動