# Using Calculate Field for If statement over many fields?

I'm struggling with the python syntax in the Calculate Field so that, in the table above:

if b, c, d, or e are NOT NULL populate the Summary field with "Verified" else populate Summary field with "In Progress"

So if any of the B, C, D or E columns contain NULL the Summary field will read "In Progress".

I believe this should be something along the lines of:

def Reclass !SUMMARY!: if [ !B! , !C! , !D! , !E!] <> NULL !SUMMARY! = "Verified: " else !SUMMARY! = "In Progress: "

Run the field calc on the Summary field. Use Python as the parser and check the Show Codeblock box.

For the Pre-Logic Script Code put:

def Reclass(B, C, D, E):
if None not in (B, C, D, E) and "" not in (B, C, D, E):
return "Verified"
else:
return "In Progess"


Then put this in the bottom box:

Reclass(!B!, !C!, !D!, !E!)


The bottom box with the ! contains the actual field names that get passed into the Reclass function in the top box.

I included the "" not in (B, C, D, E) as a check specifically for text fields that are blank but don't have the Null value, if you need it.

• @Simon Good to hear! – ianbroad Aug 8 '14 at 8:53

This answer is not meant to steal from @ian, but it shows a little bit easier way to write the code that he provided... instead of using a code block (which can be a pain in the butt sometimes when trying to write it in a standalone script...) you can rewrite his code in a single line as:

"Verified" if None not in (!B!, !C!, !D!, !E!) and "" not in (!B!, !C!, !D!, !E!) else "In Progress"