1

I am trying to create a field "conflict", and the condition is when other fields in that row have the same maximum number the function returns "Yes". I am having trouble making this work in the field calculator in ArcGIS Pro.This is what my attribute table looks like and the error I get (see pictures below).

I eventually want to see which fields(Koala, GHFF, Education, Cropping, Conservation, Cattle, and Carbon) have the same value as the "Max value" field, then use the conflict field to indicate if there is more than 1 field with the same value as the maximum value.

I'm fairly new to coding.

def conflict (Ed,Con,max):
    if max in (Con and Ed):
        return ("Yes")
    else:
        return ("No")
conflict(!Education!,!Conservation!,!MaxValue!)

enter image description here

enter image description here

enter image description here

1 Answer 1

2

Change this:

if max in (Con and Ed)

to this:

if (max == Con) and (max == Ed)

(The brackets aren't really necessary here, but they do make it more readable, in my opinion.)

(Con and Ed) evaluates to True or False ie, a boolean (or integer - hence the error regarding int being not iterable). Therefore if max in (Con and Ed) is like saying if max in True - it doesn't make any sense.

You should also be using == instead of in because (I think?) you are attempting to check if the value is equal, not if the value is included in a list (or iterable).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.