0

I am trying to calculate a percentage of a field based off the value of another field. if damage = x then return the value of field !mrkt_imprv! * y

y = percentage value 

my code is below its returning an error in the calculate field

def dam_cal():
    if !DAMAGE! == 'Affected':
        return !IMPRV_MRKT! * .1
    elif !DAMAGE! == 'Minor':
        return !IMPRV_MRKT! * .2
    elif !DAMAGE! == 'Major':
        return !IMPRV_MRKT! * .65
    elif !DAMAGE! == 'Destroyed':
        return !IMPRV_MARKT! * .85

the error is #000989 (line 2) Parameters are not valid.

| improve this question | | | | |
3

Within field calculator the field values need to be referened as a argument in the function, try this:

def dam_cal(damage, imprv_mrkt):
    if damage == 'Affected':
        return imprv_mrkt * .1
    elif damage == 'Minor':
        return imprv_mrkt * .2
    elif damage == 'Major':
        return imprv_mrkt * .65
    elif damage == 'Destroyed':
        return imprv_mrkt * .85

function call:

dam_cal(!DAMAGE!, !IMPRV_MARKT!)

You may also want to add additional logic to make sure impv_mrkt value is not NULL or 0 before multiplying it.

| improve this answer | | | | |

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