Select to view content in your preferred language

Calculate Field IF Statement

1092
3
Jump to solution
10-18-2024 01:38 PM
CameronKoehler
Emerging Contributor

I apologize in advance, I am new to ArcGIS Pro.  Is there an IF statement that can be calculated that says if the Street Name field begins with "State Highway" then return "State Highway" in the Street Pre Type field?

 

Attached is a screenshot showing the two fields in the feature class.

0 Kudos
1 Solution

Accepted Solutions
KevininMN1
Emerging Contributor

Here's a sample with a few notes in the attached screen shot.  Good luck. use of python for function with string comparisonuse of python for function with string comparison

 

View solution in original post

3 Replies
ChristopherCounsell
MVP Regular Contributor

Open the field calculator on the empty field (field1), set to Python.

In code block put your if statement in a function:

def check_value(field2):

    if "X" in field2:

        return "X"

    elif "Y" in field2:

        return "Y"

    else:

        return None 

 

Then in the top box call your function and point it at the second field:

check_value(!Field2!)

 

RonaldHaug
MVP

Hi Cameron!

Why yes there is.

I think this help page will supply you with what you need.

https://support.esri.com/en-us/knowledge-base/how-to-use-if-statements-in-calculator-field-in-arcgis...

Let us know how you did!

 

KevininMN1
Emerging Contributor

Here's a sample with a few notes in the attached screen shot.  Good luck. use of python for function with string comparisonuse of python for function with string comparison