AnsweredAssumed Answered

compare two fields if they 'are equal or not, in the field calculator

Question asked by Corderotino on Aug 20, 2014
Latest reply on Aug 21, 2014 by Corderotino

I have two "A" fields and "B" and I want to use the field calculator in the "C" field to determine if they are equal

put 1 if they are equal and 0 if they  not

  example

 

 

    A | B | C |

     3 | 3 | 1 |

     5 | 7 | 0 |

 

 

I found this scrip

but it only works in python window

 

 

import arcpy

 

 

fc = R 'c: \ path \ to \ your \ fc'

 

 

with arcpy.da.UpdateCursor (fc, ["FIELD1", "FIELD2", "FIELD3"]) as cursor:

     for row in cursor:

         if row [0] == row [1]:

             row [2] = 1

         else:

             row [2] = 0

         cursor.updateRow (row)

 

 

"I want to use the field calculator"

  or as a tool for modelbuidel where "fc = R'c: \ path \ to \ your \ fc '         can be a Shapefile imput

Outcomes