Select to view content in your preferred language

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

1177
4
Jump to solution
05-12-2021 09:35 AM
Labels (1)
wesmuilenburg
Emerging Contributor

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
Emerging Contributor

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!)

 

 

 

 



Think Location
0 Kudos
wesmuilenburg
Emerging Contributor

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.



Think Location
0 Kudos
wesmuilenburg
Emerging Contributor

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!

0 Kudos