I am trying to calculate the percentage of a total which the median value makes. I have a column with the median column labelled (i.e. 1st,2nd,3rd,4th column is median), the columns of values and the total of all values. I wrote a small python function in the Codeblock and it returns a value of 0 rather than a percentage. All the fields involved are dobule. I know I did this correctly before but I've tried almost everything to fix my code and cannot get it to return anything other than 0. Here is a screenshot of what I did in field calculator:
And here is the code written out:
def medfind(peri1,peri2,peri3,peri4,peri5,peri6,peri7,index,tot):
dict = {1:peri1,2:peri2,3:peri3,4:peri4,5:peri5,6:peri6,7:peri7}
return dict[index]/tot
I have double checked all the fields and everything does have a value. I just can't figure out why it's not working. This is in a .shp by the way, and I have previously used this function to success.