Select to view content in your preferred language

Quick field calculator IF question

1572
12
Jump to solution
11-16-2017 02:44 AM
TheodoreF
Frequent Contributor

Hi. I have a point FC with 2 text fields. 'Field 1' and 'Field 2'.

I want Field 2 to = 5 IF Field 1 = E

and also

Field 2 to = 4 IF Field 1 = D

So far I've tried this but it returned a syntax error in geoprocessing results:

if [field1] = 'E' then
  result = "5"

Could I have any solutions in VB and python if possible? Will help me learn more!

Thanks!

ArcMap 10.5.1

Tags (1)
0 Kudos
12 Replies
TheodoreF
Frequent Contributor

Thanks for the explanation Dan.

Ah both your answers worked for me! Just Jake's was a bit quicker for me to understand. Don't take it personally haha  I always appreciate your help!

0 Kudos
DanPatterson_Retired
MVP Emeritus

none taken ... I think I have a few points as a buffer..

TheodoreF
Frequent Contributor

Due to the amount of Nulls in the fields (which is expected), I can't sum together my 'score' columns (I have a few) into a final 'Total' field. ie. 4 + NULL + 5 = NULL!!!! argh So I'm going to have to edit the original code provided by Jake to return 0 if D or E values aren't found.

EDIT: solution provided above.

0 Kudos