Calculations in if statementHow to tranform a column field into a list using Field CalculatorDebugging error 000539 from ArcGIS Field Calculator?Elseif Conditional Statement in QGIS Field CalculatorRemoving return/newline (n) character from Field using Python and Field Calculator?Debugging ERROR 000539 from CalculateField in ArcPy?Python script in ArcMap Field Calculator giving Error 000539: SyntaxError: Invalid Syntax?Using Calculate Field to get acreage in ArcGIS ModelBuilder?Field Calculator Expression Assistance - Return Value Based on a Text String in Another FieldPython syntax error with If/elif statement in field calculator when using concatenationUsing Python to convert string values with Calculate Field in ArcGIS ModelBuilder?

What typically incentivizes a professor to change jobs to a lower ranking university?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

"You are your self first supporter", a more proper way to say it

What's the point of deactivating Num Lock on login screens?

What are the differences between the usage of 'it' and 'they'?

Is a conference paper whose proceedings will be published in IEEE Xplore counted as a publication?

Languages that we cannot (dis)prove to be Context-Free

Are the number of citations and number of published articles the most important criteria for a tenure promotion?

Is it legal for company to use my work email to pretend I still work there?

Finding the repeating unit of polymerisation given two constituent molecules

Today is the Center

Adding span tags within wp_list_pages list items

How much RAM could one put in a typical 80386 setup?

Why is consensus so controversial in Britain?

Dragon forelimb placement

How can bays and straits be determined in a procedurally generated map?

How to find program name(s) of an installed package?

Why is Minecraft giving an OpenGL error?

Why do falling prices hurt debtors?

Pattern match does not work in bash script

Why Is Death Allowed In the Matrix?

What is the word for reserving something for yourself before others do?

Equivalence principle before Einstein



Calculations in if statement


How to tranform a column field into a list using Field CalculatorDebugging error 000539 from ArcGIS Field Calculator?Elseif Conditional Statement in QGIS Field CalculatorRemoving return/newline (n) character from Field using Python and Field Calculator?Debugging ERROR 000539 from CalculateField in ArcPy?Python script in ArcMap Field Calculator giving Error 000539: SyntaxError: Invalid Syntax?Using Calculate Field to get acreage in ArcGIS ModelBuilder?Field Calculator Expression Assistance - Return Value Based on a Text String in Another FieldPython syntax error with If/elif statement in field calculator when using concatenationUsing Python to convert string values with Calculate Field in ArcGIS ModelBuilder?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked):



def change(OldFor_Com):
if (OldFor_Com) == "OHWH":
return shape.area@Hectares / 40
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares / 30!
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares / 30!)
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares! / 30
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares! / 30)
if (OldFor_Com == "OTHH"):
return !shape.area@hectares! / 40


If the field is populated with OTHH I want another field to be populated with the area of the field, divided by 40, or 30, or... and so on.
I modified my syntax a couple of times (as you can see) but it still says Invalid Syntax.



Is a calculation possible with these if statement or do I need a workaround?



Note that the shape.area@Hectares is an expression to calculate the area of the field, and not another field in my attributetable!



screen1



screen2



screen3



screen3



EDIT: 7/15/2014 around 11pm



I modified the script. I added a field to the table and calculate the area of the shape first (with !shape.area@Hectares!) and then I try to run this



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return Area_Ha / 40
if OldFor_Com == "OHWH":
return Area_Ha / 30
if OldFor_Com == "OSFH":
return Area_Ha / 375
if OldFor_Com == "PINE":
return Area_Ha / 10
if OldFor_Com == "OOFH":
return Area_Ha / 375
if OldFor_Com == "None":
return Area_Ha
else:
return 0


It bounces back with the following:



ERROR 000539: Error running expression: change(u"OTHH", 7) 
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: change() takes exactly 1 argument (2 given)

Failed to execute (Calculate Field (10)).


Is it not possible to do any calculations in the if statement?



EDIT: 7/15/14 12:30pm



This how the attributestable looks like before I add the field SizeScore



before



After I add the field SizeScore (FLOAT).



after



And the following screen comes up if I use this code:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
x = Area_Ha / 40
return x
if OldFor_Com == "OHWH":
x = Area_Ha / 30
return x
if OldFor_Com == "OOFH":
x = Area_Ha / 375
return x
if OldFor_Com == "OSFH":
x = Area_Ha / 375
return x
if OldFor_Com == "PINE":
x = Area_Ha / 10
return x
if OldFor_Com == "None":
return Area_Ha
else:
return 0


screen



It only populates the rows where it does not need to calculate.
The only statement that is working is that one.



if OldFor_Com == "None":
return Area_Ha


But for the others are no error messages coming back!



SOLVED, SEE ACCEPTED ANSWERE
Thanks a lot to everybody who went through this with me!










share|improve this question
























  • I don't believe you can mix/match 4 and 2 spaces. Stick with one or the other.

    – Paul
    Jul 14 '14 at 20:12











  • If I add four spaces (not six) to the third line it says intendent error. If I add six or eight it says error in the syntax. I did this intendation (four and six) in other calculations before and it worked fine.

    – Stophface
    Jul 14 '14 at 20:13











  • Try multiples of 2 or multiples of 4. First indent block is 2, then 4, then 6, etc. OR it should be 4 -> 8 -> 12 -> etc. See here, first bullet point under Note.

    – Paul
    Jul 14 '14 at 20:18











  • @ Paul thanks for the link. I will keep this in mind. There is still a mistake in the Syntax though.

    – Stophface
    Jul 14 '14 at 20:21











  • What's in your parser? And what is the field type? Is it a shapefile, SDE? etc.

    – GISKid
    Jul 14 '14 at 20:24

















1















I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked):



def change(OldFor_Com):
if (OldFor_Com) == "OHWH":
return shape.area@Hectares / 40
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares / 30!
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares / 30!)
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares! / 30
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares! / 30)
if (OldFor_Com == "OTHH"):
return !shape.area@hectares! / 40


If the field is populated with OTHH I want another field to be populated with the area of the field, divided by 40, or 30, or... and so on.
I modified my syntax a couple of times (as you can see) but it still says Invalid Syntax.



Is a calculation possible with these if statement or do I need a workaround?



Note that the shape.area@Hectares is an expression to calculate the area of the field, and not another field in my attributetable!



screen1



screen2



screen3



screen3



EDIT: 7/15/2014 around 11pm



I modified the script. I added a field to the table and calculate the area of the shape first (with !shape.area@Hectares!) and then I try to run this



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return Area_Ha / 40
if OldFor_Com == "OHWH":
return Area_Ha / 30
if OldFor_Com == "OSFH":
return Area_Ha / 375
if OldFor_Com == "PINE":
return Area_Ha / 10
if OldFor_Com == "OOFH":
return Area_Ha / 375
if OldFor_Com == "None":
return Area_Ha
else:
return 0


It bounces back with the following:



ERROR 000539: Error running expression: change(u"OTHH", 7) 
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: change() takes exactly 1 argument (2 given)

Failed to execute (Calculate Field (10)).


Is it not possible to do any calculations in the if statement?



EDIT: 7/15/14 12:30pm



This how the attributestable looks like before I add the field SizeScore



before



After I add the field SizeScore (FLOAT).



after



And the following screen comes up if I use this code:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
x = Area_Ha / 40
return x
if OldFor_Com == "OHWH":
x = Area_Ha / 30
return x
if OldFor_Com == "OOFH":
x = Area_Ha / 375
return x
if OldFor_Com == "OSFH":
x = Area_Ha / 375
return x
if OldFor_Com == "PINE":
x = Area_Ha / 10
return x
if OldFor_Com == "None":
return Area_Ha
else:
return 0


screen



It only populates the rows where it does not need to calculate.
The only statement that is working is that one.



if OldFor_Com == "None":
return Area_Ha


But for the others are no error messages coming back!



SOLVED, SEE ACCEPTED ANSWERE
Thanks a lot to everybody who went through this with me!










share|improve this question
























  • I don't believe you can mix/match 4 and 2 spaces. Stick with one or the other.

    – Paul
    Jul 14 '14 at 20:12











  • If I add four spaces (not six) to the third line it says intendent error. If I add six or eight it says error in the syntax. I did this intendation (four and six) in other calculations before and it worked fine.

    – Stophface
    Jul 14 '14 at 20:13











  • Try multiples of 2 or multiples of 4. First indent block is 2, then 4, then 6, etc. OR it should be 4 -> 8 -> 12 -> etc. See here, first bullet point under Note.

    – Paul
    Jul 14 '14 at 20:18











  • @ Paul thanks for the link. I will keep this in mind. There is still a mistake in the Syntax though.

    – Stophface
    Jul 14 '14 at 20:21











  • What's in your parser? And what is the field type? Is it a shapefile, SDE? etc.

    – GISKid
    Jul 14 '14 at 20:24













1












1








1








I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked):



def change(OldFor_Com):
if (OldFor_Com) == "OHWH":
return shape.area@Hectares / 40
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares / 30!
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares / 30!)
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares! / 30
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares! / 30)
if (OldFor_Com == "OTHH"):
return !shape.area@hectares! / 40


If the field is populated with OTHH I want another field to be populated with the area of the field, divided by 40, or 30, or... and so on.
I modified my syntax a couple of times (as you can see) but it still says Invalid Syntax.



Is a calculation possible with these if statement or do I need a workaround?



Note that the shape.area@Hectares is an expression to calculate the area of the field, and not another field in my attributetable!



screen1



screen2



screen3



screen3



EDIT: 7/15/2014 around 11pm



I modified the script. I added a field to the table and calculate the area of the shape first (with !shape.area@Hectares!) and then I try to run this



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return Area_Ha / 40
if OldFor_Com == "OHWH":
return Area_Ha / 30
if OldFor_Com == "OSFH":
return Area_Ha / 375
if OldFor_Com == "PINE":
return Area_Ha / 10
if OldFor_Com == "OOFH":
return Area_Ha / 375
if OldFor_Com == "None":
return Area_Ha
else:
return 0


It bounces back with the following:



ERROR 000539: Error running expression: change(u"OTHH", 7) 
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: change() takes exactly 1 argument (2 given)

Failed to execute (Calculate Field (10)).


Is it not possible to do any calculations in the if statement?



EDIT: 7/15/14 12:30pm



This how the attributestable looks like before I add the field SizeScore



before



After I add the field SizeScore (FLOAT).



after



And the following screen comes up if I use this code:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
x = Area_Ha / 40
return x
if OldFor_Com == "OHWH":
x = Area_Ha / 30
return x
if OldFor_Com == "OOFH":
x = Area_Ha / 375
return x
if OldFor_Com == "OSFH":
x = Area_Ha / 375
return x
if OldFor_Com == "PINE":
x = Area_Ha / 10
return x
if OldFor_Com == "None":
return Area_Ha
else:
return 0


screen



It only populates the rows where it does not need to calculate.
The only statement that is working is that one.



if OldFor_Com == "None":
return Area_Ha


But for the others are no error messages coming back!



SOLVED, SEE ACCEPTED ANSWERE
Thanks a lot to everybody who went through this with me!










share|improve this question
















I want to perform a simple calculation with the Field Calculator using this piece of script (note that all the elif statements are attempts for another syntax and non of the worked):



def change(OldFor_Com):
if (OldFor_Com) == "OHWH":
return shape.area@Hectares / 40
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares / 30!
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares / 30!)
elif (OldFor_Com) == "OHWH":
return !shape.area@Hectares! / 30
elif (OldFor_Com) == "OHWH":
return (!shape.area@Hectares! / 30)
if (OldFor_Com == "OTHH"):
return !shape.area@hectares! / 40


If the field is populated with OTHH I want another field to be populated with the area of the field, divided by 40, or 30, or... and so on.
I modified my syntax a couple of times (as you can see) but it still says Invalid Syntax.



Is a calculation possible with these if statement or do I need a workaround?



Note that the shape.area@Hectares is an expression to calculate the area of the field, and not another field in my attributetable!



screen1



screen2



screen3



screen3



EDIT: 7/15/2014 around 11pm



I modified the script. I added a field to the table and calculate the area of the shape first (with !shape.area@Hectares!) and then I try to run this



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return Area_Ha / 40
if OldFor_Com == "OHWH":
return Area_Ha / 30
if OldFor_Com == "OSFH":
return Area_Ha / 375
if OldFor_Com == "PINE":
return Area_Ha / 10
if OldFor_Com == "OOFH":
return Area_Ha / 375
if OldFor_Com == "None":
return Area_Ha
else:
return 0


It bounces back with the following:



ERROR 000539: Error running expression: change(u"OTHH", 7) 
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: change() takes exactly 1 argument (2 given)

Failed to execute (Calculate Field (10)).


Is it not possible to do any calculations in the if statement?



EDIT: 7/15/14 12:30pm



This how the attributestable looks like before I add the field SizeScore



before



After I add the field SizeScore (FLOAT).



after



And the following screen comes up if I use this code:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
x = Area_Ha / 40
return x
if OldFor_Com == "OHWH":
x = Area_Ha / 30
return x
if OldFor_Com == "OOFH":
x = Area_Ha / 375
return x
if OldFor_Com == "OSFH":
x = Area_Ha / 375
return x
if OldFor_Com == "PINE":
x = Area_Ha / 10
return x
if OldFor_Com == "None":
return Area_Ha
else:
return 0


screen



It only populates the rows where it does not need to calculate.
The only statement that is working is that one.



if OldFor_Com == "None":
return Area_Ha


But for the others are no error messages coming back!



SOLVED, SEE ACCEPTED ANSWERE
Thanks a lot to everybody who went through this with me!







arcgis-desktop arcgis-10.2 field-calculator python-parser error-000539






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 2 at 20:43









Glorfindel

2831311




2831311










asked Jul 14 '14 at 19:55









StophfaceStophface

1,19811539




1,19811539












  • I don't believe you can mix/match 4 and 2 spaces. Stick with one or the other.

    – Paul
    Jul 14 '14 at 20:12











  • If I add four spaces (not six) to the third line it says intendent error. If I add six or eight it says error in the syntax. I did this intendation (four and six) in other calculations before and it worked fine.

    – Stophface
    Jul 14 '14 at 20:13











  • Try multiples of 2 or multiples of 4. First indent block is 2, then 4, then 6, etc. OR it should be 4 -> 8 -> 12 -> etc. See here, first bullet point under Note.

    – Paul
    Jul 14 '14 at 20:18











  • @ Paul thanks for the link. I will keep this in mind. There is still a mistake in the Syntax though.

    – Stophface
    Jul 14 '14 at 20:21











  • What's in your parser? And what is the field type? Is it a shapefile, SDE? etc.

    – GISKid
    Jul 14 '14 at 20:24

















  • I don't believe you can mix/match 4 and 2 spaces. Stick with one or the other.

    – Paul
    Jul 14 '14 at 20:12











  • If I add four spaces (not six) to the third line it says intendent error. If I add six or eight it says error in the syntax. I did this intendation (four and six) in other calculations before and it worked fine.

    – Stophface
    Jul 14 '14 at 20:13











  • Try multiples of 2 or multiples of 4. First indent block is 2, then 4, then 6, etc. OR it should be 4 -> 8 -> 12 -> etc. See here, first bullet point under Note.

    – Paul
    Jul 14 '14 at 20:18











  • @ Paul thanks for the link. I will keep this in mind. There is still a mistake in the Syntax though.

    – Stophface
    Jul 14 '14 at 20:21











  • What's in your parser? And what is the field type? Is it a shapefile, SDE? etc.

    – GISKid
    Jul 14 '14 at 20:24
















I don't believe you can mix/match 4 and 2 spaces. Stick with one or the other.

– Paul
Jul 14 '14 at 20:12





I don't believe you can mix/match 4 and 2 spaces. Stick with one or the other.

– Paul
Jul 14 '14 at 20:12













If I add four spaces (not six) to the third line it says intendent error. If I add six or eight it says error in the syntax. I did this intendation (four and six) in other calculations before and it worked fine.

– Stophface
Jul 14 '14 at 20:13





If I add four spaces (not six) to the third line it says intendent error. If I add six or eight it says error in the syntax. I did this intendation (four and six) in other calculations before and it worked fine.

– Stophface
Jul 14 '14 at 20:13













Try multiples of 2 or multiples of 4. First indent block is 2, then 4, then 6, etc. OR it should be 4 -> 8 -> 12 -> etc. See here, first bullet point under Note.

– Paul
Jul 14 '14 at 20:18





Try multiples of 2 or multiples of 4. First indent block is 2, then 4, then 6, etc. OR it should be 4 -> 8 -> 12 -> etc. See here, first bullet point under Note.

– Paul
Jul 14 '14 at 20:18













@ Paul thanks for the link. I will keep this in mind. There is still a mistake in the Syntax though.

– Stophface
Jul 14 '14 at 20:21





@ Paul thanks for the link. I will keep this in mind. There is still a mistake in the Syntax though.

– Stophface
Jul 14 '14 at 20:21













What's in your parser? And what is the field type? Is it a shapefile, SDE? etc.

– GISKid
Jul 14 '14 at 20:24





What's in your parser? And what is the field type? Is it a shapefile, SDE? etc.

– GISKid
Jul 14 '14 at 20:24










4 Answers
4






active

oldest

votes


















1














After your newest updates to the question, this should work:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
return Area_Ha / 40.0
elif OldFor_Com == "OHWH":
return Area_Ha / 30.0
elif OldFor_Com == "OOFH":
return Area_Ha / 375.0
elif OldFor_Com == "OSFH":
return Area_Ha / 375.0
elif OldFor_Com == "PINE":
return Area_Ha / 10.0
elif OldFor_Com == "None":
return Area_Ha
else:
return 0


The reason you were seeing all 0s (except for the "None" case) was not that the function wasn't working, but rather that you were dividing integers by integers. The results were always less than 1, and Python always rounds down for integer math. Adding .0 to each of the denominators forces decimal math, and the results will be decimals.



(Alternatively -- and this is probably better -- is to make the "Area_Ha" field a float/double instead of an integer. Then your function would work exactly as you've written it.)






share|improve this answer

























  • Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

    – Stophface
    Jul 15 '14 at 17:05











  • You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

    – GISKid
    Jul 15 '14 at 17:09












  • Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

    – nmpeterson
    Jul 15 '14 at 17:12


















2














You need to send your area field into your calculation as a parameter.



Expression: change(!OldFor_Com!, !shape.area@hectares!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30





share|improve this answer

























  • The setting of the ! I tried in my third elif statement. Does not work.

    – Stophface
    Jul 14 '14 at 20:08











  • Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

    – evv_gis
    Jul 14 '14 at 20:08











  • Edit my question. With this syntax I added to the post the error is in the third line.

    – Stophface
    Jul 14 '14 at 20:10











  • I updated the indentation, looks like I was off by one.

    – evv_gis
    Jul 14 '14 at 20:17











  • The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

    – Stophface
    Jul 14 '14 at 20:19


















1














Your exclamation marks need to be wrapped around the field name:



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return !shape.area@Hectares! / 40
elif OldFor_Com == "OHWH":
return !shape.area@Hectares! / 30


Also, make sure Python is the defined Parser.






share|improve this answer

























  • Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

    – Stophface
    Jul 14 '14 at 20:07











  • Updated, removed some unnecessary parentheses.

    – artwork21
    Jul 14 '14 at 20:09











  • @artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

    – GISKid
    Jul 14 '14 at 20:11











  • Yep GISKid, that what I did

    – Stophface
    Jul 14 '14 at 20:11






  • 2





    In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

    – Michael Stimson
    Jul 14 '14 at 22:15



















0














Going off of your latest edit and ew_GIS try this:



Expression: change(!OldFor_Com!, !Area_Ha!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30
elif OldFor_Com in ("OOFH", "OSFH", "OOFH"):
return area / 375
elif OldFor_Com == "PINE":
return area / 10
elif OldFor_Com == "None":
return area
else:
return 0





share|improve this answer

























  • Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

    – Stophface
    Jul 15 '14 at 15:30











  • Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

    – GISKid
    Jul 15 '14 at 15:35











  • It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

    – Stophface
    Jul 15 '14 at 15:39











  • OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

    – Paul
    Jul 15 '14 at 16:07












  • Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

    – GISKid
    Jul 15 '14 at 16:13











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f107155%2fcalculations-in-if-statement%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























4 Answers
4






active

oldest

votes








4 Answers
4






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














After your newest updates to the question, this should work:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
return Area_Ha / 40.0
elif OldFor_Com == "OHWH":
return Area_Ha / 30.0
elif OldFor_Com == "OOFH":
return Area_Ha / 375.0
elif OldFor_Com == "OSFH":
return Area_Ha / 375.0
elif OldFor_Com == "PINE":
return Area_Ha / 10.0
elif OldFor_Com == "None":
return Area_Ha
else:
return 0


The reason you were seeing all 0s (except for the "None" case) was not that the function wasn't working, but rather that you were dividing integers by integers. The results were always less than 1, and Python always rounds down for integer math. Adding .0 to each of the denominators forces decimal math, and the results will be decimals.



(Alternatively -- and this is probably better -- is to make the "Area_Ha" field a float/double instead of an integer. Then your function would work exactly as you've written it.)






share|improve this answer

























  • Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

    – Stophface
    Jul 15 '14 at 17:05











  • You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

    – GISKid
    Jul 15 '14 at 17:09












  • Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

    – nmpeterson
    Jul 15 '14 at 17:12















1














After your newest updates to the question, this should work:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
return Area_Ha / 40.0
elif OldFor_Com == "OHWH":
return Area_Ha / 30.0
elif OldFor_Com == "OOFH":
return Area_Ha / 375.0
elif OldFor_Com == "OSFH":
return Area_Ha / 375.0
elif OldFor_Com == "PINE":
return Area_Ha / 10.0
elif OldFor_Com == "None":
return Area_Ha
else:
return 0


The reason you were seeing all 0s (except for the "None" case) was not that the function wasn't working, but rather that you were dividing integers by integers. The results were always less than 1, and Python always rounds down for integer math. Adding .0 to each of the denominators forces decimal math, and the results will be decimals.



(Alternatively -- and this is probably better -- is to make the "Area_Ha" field a float/double instead of an integer. Then your function would work exactly as you've written it.)






share|improve this answer

























  • Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

    – Stophface
    Jul 15 '14 at 17:05











  • You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

    – GISKid
    Jul 15 '14 at 17:09












  • Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

    – nmpeterson
    Jul 15 '14 at 17:12













1












1








1







After your newest updates to the question, this should work:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
return Area_Ha / 40.0
elif OldFor_Com == "OHWH":
return Area_Ha / 30.0
elif OldFor_Com == "OOFH":
return Area_Ha / 375.0
elif OldFor_Com == "OSFH":
return Area_Ha / 375.0
elif OldFor_Com == "PINE":
return Area_Ha / 10.0
elif OldFor_Com == "None":
return Area_Ha
else:
return 0


The reason you were seeing all 0s (except for the "None" case) was not that the function wasn't working, but rather that you were dividing integers by integers. The results were always less than 1, and Python always rounds down for integer math. Adding .0 to each of the denominators forces decimal math, and the results will be decimals.



(Alternatively -- and this is probably better -- is to make the "Area_Ha" field a float/double instead of an integer. Then your function would work exactly as you've written it.)






share|improve this answer















After your newest updates to the question, this should work:



def change(OldFor_Com, Area_Ha):
if OldFor_Com == "OTHH":
return Area_Ha / 40.0
elif OldFor_Com == "OHWH":
return Area_Ha / 30.0
elif OldFor_Com == "OOFH":
return Area_Ha / 375.0
elif OldFor_Com == "OSFH":
return Area_Ha / 375.0
elif OldFor_Com == "PINE":
return Area_Ha / 10.0
elif OldFor_Com == "None":
return Area_Ha
else:
return 0


The reason you were seeing all 0s (except for the "None" case) was not that the function wasn't working, but rather that you were dividing integers by integers. The results were always less than 1, and Python always rounds down for integer math. Adding .0 to each of the denominators forces decimal math, and the results will be decimals.



(Alternatively -- and this is probably better -- is to make the "Area_Ha" field a float/double instead of an integer. Then your function would work exactly as you've written it.)







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 15 '14 at 17:11

























answered Jul 15 '14 at 16:43









nmpetersonnmpeterson

7,4002555




7,4002555












  • Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

    – Stophface
    Jul 15 '14 at 17:05











  • You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

    – GISKid
    Jul 15 '14 at 17:09












  • Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

    – nmpeterson
    Jul 15 '14 at 17:12

















  • Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

    – Stophface
    Jul 15 '14 at 17:05











  • You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

    – GISKid
    Jul 15 '14 at 17:09












  • Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

    – nmpeterson
    Jul 15 '14 at 17:12
















Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

– Stophface
Jul 15 '14 at 17:05





Awesome dude. Thats working now! Thanks a lot for the explanation! Now I am a little bit more pythionic again :) Till he next problem which is probably just waiting around the corner. Could you explain why I need the variable x though?

– Stophface
Jul 15 '14 at 17:05













You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

– GISKid
Jul 15 '14 at 17:09






You don't, I added that in there to see what was going on in the original cod. it should work if you take out the x and just use return area / 10.0

– GISKid
Jul 15 '14 at 17:09














Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

– nmpeterson
Jul 15 '14 at 17:12





Yeah, you don't need an intermediate variable. I cleaned up the code in the answer and added the elifs back in to make the code more efficient.

– nmpeterson
Jul 15 '14 at 17:12













2














You need to send your area field into your calculation as a parameter.



Expression: change(!OldFor_Com!, !shape.area@hectares!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30





share|improve this answer

























  • The setting of the ! I tried in my third elif statement. Does not work.

    – Stophface
    Jul 14 '14 at 20:08











  • Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

    – evv_gis
    Jul 14 '14 at 20:08











  • Edit my question. With this syntax I added to the post the error is in the third line.

    – Stophface
    Jul 14 '14 at 20:10











  • I updated the indentation, looks like I was off by one.

    – evv_gis
    Jul 14 '14 at 20:17











  • The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

    – Stophface
    Jul 14 '14 at 20:19















2














You need to send your area field into your calculation as a parameter.



Expression: change(!OldFor_Com!, !shape.area@hectares!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30





share|improve this answer

























  • The setting of the ! I tried in my third elif statement. Does not work.

    – Stophface
    Jul 14 '14 at 20:08











  • Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

    – evv_gis
    Jul 14 '14 at 20:08











  • Edit my question. With this syntax I added to the post the error is in the third line.

    – Stophface
    Jul 14 '14 at 20:10











  • I updated the indentation, looks like I was off by one.

    – evv_gis
    Jul 14 '14 at 20:17











  • The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

    – Stophface
    Jul 14 '14 at 20:19













2












2








2







You need to send your area field into your calculation as a parameter.



Expression: change(!OldFor_Com!, !shape.area@hectares!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30





share|improve this answer















You need to send your area field into your calculation as a parameter.



Expression: change(!OldFor_Com!, !shape.area@hectares!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30






share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 15 '14 at 12:43

























answered Jul 14 '14 at 20:01









evv_gisevv_gis

2,5051123




2,5051123












  • The setting of the ! I tried in my third elif statement. Does not work.

    – Stophface
    Jul 14 '14 at 20:08











  • Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

    – evv_gis
    Jul 14 '14 at 20:08











  • Edit my question. With this syntax I added to the post the error is in the third line.

    – Stophface
    Jul 14 '14 at 20:10











  • I updated the indentation, looks like I was off by one.

    – evv_gis
    Jul 14 '14 at 20:17











  • The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

    – Stophface
    Jul 14 '14 at 20:19

















  • The setting of the ! I tried in my third elif statement. Does not work.

    – Stophface
    Jul 14 '14 at 20:08











  • Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

    – evv_gis
    Jul 14 '14 at 20:08











  • Edit my question. With this syntax I added to the post the error is in the third line.

    – Stophface
    Jul 14 '14 at 20:10











  • I updated the indentation, looks like I was off by one.

    – evv_gis
    Jul 14 '14 at 20:17











  • The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

    – Stophface
    Jul 14 '14 at 20:19
















The setting of the ! I tried in my third elif statement. Does not work.

– Stophface
Jul 14 '14 at 20:08





The setting of the ! I tried in my third elif statement. Does not work.

– Stophface
Jul 14 '14 at 20:08













Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

– evv_gis
Jul 14 '14 at 20:08





Is the invalid syntax being reported before the third line? If so, the calculation never gets there to attempt that syntax.

– evv_gis
Jul 14 '14 at 20:08













Edit my question. With this syntax I added to the post the error is in the third line.

– Stophface
Jul 14 '14 at 20:10





Edit my question. With this syntax I added to the post the error is in the third line.

– Stophface
Jul 14 '14 at 20:10













I updated the indentation, looks like I was off by one.

– evv_gis
Jul 14 '14 at 20:17





I updated the indentation, looks like I was off by one.

– evv_gis
Jul 14 '14 at 20:17













The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

– Stophface
Jul 14 '14 at 20:19





The intendation is fine. I get a different error message if the intendation is wrong. It is still the syntax

– Stophface
Jul 14 '14 at 20:19











1














Your exclamation marks need to be wrapped around the field name:



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return !shape.area@Hectares! / 40
elif OldFor_Com == "OHWH":
return !shape.area@Hectares! / 30


Also, make sure Python is the defined Parser.






share|improve this answer

























  • Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

    – Stophface
    Jul 14 '14 at 20:07











  • Updated, removed some unnecessary parentheses.

    – artwork21
    Jul 14 '14 at 20:09











  • @artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

    – GISKid
    Jul 14 '14 at 20:11











  • Yep GISKid, that what I did

    – Stophface
    Jul 14 '14 at 20:11






  • 2





    In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

    – Michael Stimson
    Jul 14 '14 at 22:15
















1














Your exclamation marks need to be wrapped around the field name:



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return !shape.area@Hectares! / 40
elif OldFor_Com == "OHWH":
return !shape.area@Hectares! / 30


Also, make sure Python is the defined Parser.






share|improve this answer

























  • Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

    – Stophface
    Jul 14 '14 at 20:07











  • Updated, removed some unnecessary parentheses.

    – artwork21
    Jul 14 '14 at 20:09











  • @artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

    – GISKid
    Jul 14 '14 at 20:11











  • Yep GISKid, that what I did

    – Stophface
    Jul 14 '14 at 20:11






  • 2





    In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

    – Michael Stimson
    Jul 14 '14 at 22:15














1












1








1







Your exclamation marks need to be wrapped around the field name:



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return !shape.area@Hectares! / 40
elif OldFor_Com == "OHWH":
return !shape.area@Hectares! / 30


Also, make sure Python is the defined Parser.






share|improve this answer















Your exclamation marks need to be wrapped around the field name:



def change(OldFor_Com):
if OldFor_Com == "OTHH":
return !shape.area@Hectares! / 40
elif OldFor_Com == "OHWH":
return !shape.area@Hectares! / 30


Also, make sure Python is the defined Parser.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 14 '14 at 20:53









nmpeterson

7,4002555




7,4002555










answered Jul 14 '14 at 20:00









artwork21artwork21

31.1k554120




31.1k554120












  • Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

    – Stophface
    Jul 14 '14 at 20:07











  • Updated, removed some unnecessary parentheses.

    – artwork21
    Jul 14 '14 at 20:09











  • @artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

    – GISKid
    Jul 14 '14 at 20:11











  • Yep GISKid, that what I did

    – Stophface
    Jul 14 '14 at 20:11






  • 2





    In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

    – Michael Stimson
    Jul 14 '14 at 22:15


















  • Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

    – Stophface
    Jul 14 '14 at 20:07











  • Updated, removed some unnecessary parentheses.

    – artwork21
    Jul 14 '14 at 20:09











  • @artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

    – GISKid
    Jul 14 '14 at 20:11











  • Yep GISKid, that what I did

    – Stophface
    Jul 14 '14 at 20:11






  • 2





    In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

    – Michael Stimson
    Jul 14 '14 at 22:15

















Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

– Stophface
Jul 14 '14 at 20:07





Thats what I tried in my third elif statement. Does not work. Python is defined as parser.

– Stophface
Jul 14 '14 at 20:07













Updated, removed some unnecessary parentheses.

– artwork21
Jul 14 '14 at 20:09





Updated, removed some unnecessary parentheses.

– artwork21
Jul 14 '14 at 20:09













@artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

– GISKid
Jul 14 '14 at 20:11





@artwork21 you only need one if statement for "OHWH" as well. I think OP was just testing multiple formattings to see if it would work.

– GISKid
Jul 14 '14 at 20:11













Yep GISKid, that what I did

– Stophface
Jul 14 '14 at 20:11





Yep GISKid, that what I did

– Stophface
Jul 14 '14 at 20:11




2




2





In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

– Michael Stimson
Jul 14 '14 at 22:15






In the python code block the !shape.area! is out of scope this is a very common misconception. See this page resources.arcgis.com/en/help/main/10.2/index.html#//… for explanation. The exclamation marks go in the expression not the code block. the answer by @ew_gis is correct except the expression should be change(OldFor_Com!, !shape.area@Hectares!)

– Michael Stimson
Jul 14 '14 at 22:15












0














Going off of your latest edit and ew_GIS try this:



Expression: change(!OldFor_Com!, !Area_Ha!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30
elif OldFor_Com in ("OOFH", "OSFH", "OOFH"):
return area / 375
elif OldFor_Com == "PINE":
return area / 10
elif OldFor_Com == "None":
return area
else:
return 0





share|improve this answer

























  • Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

    – Stophface
    Jul 15 '14 at 15:30











  • Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

    – GISKid
    Jul 15 '14 at 15:35











  • It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

    – Stophface
    Jul 15 '14 at 15:39











  • OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

    – Paul
    Jul 15 '14 at 16:07












  • Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

    – GISKid
    Jul 15 '14 at 16:13















0














Going off of your latest edit and ew_GIS try this:



Expression: change(!OldFor_Com!, !Area_Ha!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30
elif OldFor_Com in ("OOFH", "OSFH", "OOFH"):
return area / 375
elif OldFor_Com == "PINE":
return area / 10
elif OldFor_Com == "None":
return area
else:
return 0





share|improve this answer

























  • Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

    – Stophface
    Jul 15 '14 at 15:30











  • Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

    – GISKid
    Jul 15 '14 at 15:35











  • It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

    – Stophface
    Jul 15 '14 at 15:39











  • OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

    – Paul
    Jul 15 '14 at 16:07












  • Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

    – GISKid
    Jul 15 '14 at 16:13













0












0








0







Going off of your latest edit and ew_GIS try this:



Expression: change(!OldFor_Com!, !Area_Ha!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30
elif OldFor_Com in ("OOFH", "OSFH", "OOFH"):
return area / 375
elif OldFor_Com == "PINE":
return area / 10
elif OldFor_Com == "None":
return area
else:
return 0





share|improve this answer















Going off of your latest edit and ew_GIS try this:



Expression: change(!OldFor_Com!, !Area_Ha!)



Code Block:



def change(OldFor_Com, area):
if OldFor_Com == "OTHH":
return area / 40
elif OldFor_Com == "OHWH":
return area / 30
elif OldFor_Com in ("OOFH", "OSFH", "OOFH"):
return area / 375
elif OldFor_Com == "PINE":
return area / 10
elif OldFor_Com == "None":
return area
else:
return 0






share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 15 '14 at 17:03

























answered Jul 15 '14 at 15:11









GISKidGISKid

2,6201235




2,6201235












  • Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

    – Stophface
    Jul 15 '14 at 15:30











  • Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

    – GISKid
    Jul 15 '14 at 15:35











  • It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

    – Stophface
    Jul 15 '14 at 15:39











  • OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

    – Paul
    Jul 15 '14 at 16:07












  • Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

    – GISKid
    Jul 15 '14 at 16:13

















  • Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

    – Stophface
    Jul 15 '14 at 15:30











  • Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

    – GISKid
    Jul 15 '14 at 15:35











  • It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

    – Stophface
    Jul 15 '14 at 15:39











  • OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

    – Paul
    Jul 15 '14 at 16:07












  • Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

    – GISKid
    Jul 15 '14 at 16:13
















Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

– Stophface
Jul 15 '14 at 15:30





Thanks for your effort. I edited my post! The OR statement does not work, Field Calculator does not like the syntax so I made it an extra elif argument.

– Stophface
Jul 15 '14 at 15:30













Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

– GISKid
Jul 15 '14 at 15:35





Strange, could you try running it as a stand-alone script instead of in the field calculator? I'm out of touch with ArcGIS 9.3. It's been some time.

– GISKid
Jul 15 '14 at 15:35













It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

– Stophface
Jul 15 '14 at 15:39





It should work in the Field Calculator shouldnt it? I could try running it as a standalone script but it needs to be included in the modelbuilder. Its ArcGis 10.2 I am working with

– Stophface
Jul 15 '14 at 15:39













OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

– Paul
Jul 15 '14 at 16:07






OR does not work because it should be or. Alternatively, use elif OldFor_Com in ("OSFH", "OOFH"):

– Paul
Jul 15 '14 at 16:07














Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

– GISKid
Jul 15 '14 at 16:13





Thanks Paul! I'm still a rookie @Stophface See my edit, I just tested it and it worked.

– GISKid
Jul 15 '14 at 16:13

















draft saved

draft discarded
















































Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f107155%2fcalculations-in-if-statement%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221