I need to calculate ratio between two numbers than to percent but some rows in both field1 and field2 have zero values.
Simple calculator field2 / field1 * 100 but field1 has zeros, how do I by pass the rows with zeros in field1 in field calculator?
Field 1 field 2
0 15200 --> can't divide 0/15200
Solved! Go to Solution.
Put the following in the expression box using a Python parser:
!field2!/!field1!*100 if !field1! else None
Are you doing this in python or just the field calculator? Either way, select out those records that meet your criteria then apply the calculation.
Ya I could have done it that way but I want to know who to do it through field calculator.
Put the following in the expression box using a Python parser:
!field2!/!field1!*100 if !field1! else None
I get "There was a failure during processing". Error 999999 & the field is not nullable.
Some rows do have zero if both fields.
Try replacing the None in Joshua Bixby's line of code with 0.
Not sure why I didn't think of that big give away "field is not nullable."