HOW TO

Anwenden von Bedingungsfunktionen in Arcade-Ausdrücken zur Beschriftung bei NULL- oder NOT NULL-Werten in ArcGIS Pro

Last Published: May 8, 2024

Zusammenfassung

In ArcGIS Pro, Arcade conditional functions can be used to reference two or more fields of an attribute table using the Calculate tool. This improves readability of the field values and provides uniformity, if there is a limit to the number of characters applicable.

This article provides the workflow to use the Field Calculator in ArcGIS Pro to create a new field by referencing more than one field that has NULL or NOT NULL values in the attribute table. In this example, the COMPILE field is created by referencing field values from LEVEL, COUNTY, DISTRICT, and DIST_NO if the value in the LEVEL field is Administration.

An attribute table in ArcGIS Pro with the fields COMPILE, LEVEL, COUNTY, DISTRICT, and DIST_NO on display

Vorgehensweise

  1. Start ArcGIS Pro and open the project.
  2. In the Contents pane, right-click the feature class and click Attribute Table to open the attribute table.
Selecting Attribute Table of a feature class in the Contents pane
  1. In the feature class attribute table, click Calculate The Calculate icon in the Attribute Table in the attribute table to open the Calculate Field geoprocessing tool.
Click Calculate Field in the Attribute Table pane
  1. In the Calculate Field tool dialog box, configure the following parameters.
    1. For Field Name (Existing or New), select the available field to update the existing field. Alternatively, create a new field name.
    2. If a new field is created, for Field Type, select the preferred field type. Refer to ArcGIS Pro: ArcGIS field data types for more information.
    3. For Expression Type, select Arcade.
    4. Specify the following Arcade expression in the Expression section:
var <variable1> = $feature.<fieldName1>
var <variable2> = $feature.<fieldName2>
var <variable3> = $feature.<fieldName3>
var <variable4> = $feature.<fieldName4>

if (<variable1> == '<fieldValue>') {
    if (!isEmpty(<variable4>) && !isEmpty(<variable3>)) {
        return <variable4> + ' - ' + <variable3> }
    else if (!isEmpty(<variable4>)) {
        return <variable4> }
    else if (!isEmpty(<variable3>)) {
        return <variable3> + <variable2> }
else {
    return null }
}
Note:
Refer to ArcGIS Pro: Calculate Field expressions for further information on Python expressions.
  1. Click OK.
The Calculate Field pane with Field Name, Field Type, and Expression Type selected, and the expression added

Artikel-ID:000027492

Benachrichtigungen erhalten und Lösungen für neue oder häufige Probleme finden

Unser neuer KI-Chatbot stellt zusammengefasste Antworten und Videolösungen für Sie bereit.

Esri Support App herunterladen

Zugehörige Informationen

Weitere Informationen zu diesem Thema erkunden

Unterstützung durch ArcGIS-Experten anfordern

An den technischen Support wenden

Esri Support App herunterladen

Zu Download-Optionen wechseln