Python If/Then expression calculating one field based on different field in ArcMap10.2

152
4
Jump to solution
05-12-2021 09:35 AM
Labels (1)
wesmuilenburg
New Contributor II

I want to calculate Inspection Cycle Totals based on the field Inspection Cycle using python.  

If Inspection Cycle in Null, then calc Inspection Cycle Totals to zero 0.

If Inspection Cycle already has a value, then calc that value into Cycle Totals.

Note:  Inspection Cycle is a short integer.  Inspection Cycle Total is a text field.

Thanks in advance for any assistance.

 

0 Kudos
1 Solution

Accepted Solutions
wesmuilenburg
New Contributor II

Jayanta,  I have a solution.  I added () around if statement.   I have enclosed an image of the solution to assist the community of users.   

Thanks again!

View solution in original post

0 Kudos
4 Replies
JayantaPoddar
MVP Esteemed Contributor

Just keep 1 variable in the function, i.e., Inspection_Cycle. 

Also in your workflow, function name is different in Code Block and in Expression.

 

def classify(Inspection_Cycle):

Expression:

 

 

classify(!Inspection_Cycle!)

 

 

 

 

0 Kudos
wesmuilenburg
New Contributor II

Jayanta, Thanks for the quick response.  I have enclosed two images which further show my intention and python code.  I am still having a bit of trouble. 

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

The If statement line should end with colon (:)

That's why the code (Python_fieldcalc_2.jpg) didn't run.

0 Kudos
wesmuilenburg
New Contributor II

Jayanta,  I have a solution.  I added () around if statement.   I have enclosed an image of the solution to assist the community of users.   

Thanks again!

View solution in original post

0 Kudos