Hey all,
I am new to Python. I am currently trying to write a calculation using Python in the field calculator ONLY IF another field equals a specific value.
For instance, I have a MAINTENANCECOMPLETE field, a MAINTENANCETYPE field, a DEFMAINTENANCE field, and a COST field.
I want the MAINTENANCECOMPLETE field to populate the sum of DEFMAINTENANCE and COST only if MAINTENANCETYPE is equal to "DM General."
Here is what I currently have:
Code Block:
def ifBlock(maintenanceType):
if maintenanceType== 'DM General'
return !DEFMAINTENANCE! - !Cost!
Actual Code:
ifBlock(!MaintenanceType!)
How should I write this differently?
Let me know if I can clarify in any way.