Skip to main content
edited tags; edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to use Using ArcMap Field Calculator to count the number of identical values?

formatting
Source Link

I have a file with an attribute table with data in 3 columns, and would like to use field calculator to populate a 4th column. The data is integer numbers between 0 and 56. I want the new column to tell if the numbers in the 3 previous columns are identical or not. I would like the 4th column to state "3" if all 3 columns have the same number, "2" if 2 are the same, and "0" if none of the columns contain the same number. 

Does anyone know how to do this calculation?

I tried the following in Python:
def (Lik_grtyp):
if [Grunntype]== [Grunntyp_1] AND [Grunntyp_1]== [Grunntyp_2]:
return 3
elseif [Grunntyp_1]== [Grunntyp_2] OR[Grunntype] == [Grunntyp_1] OR [Grunntyp_2]== [Grunntype]:
return 2
elseif [Grunntyp_1]!=[Grunntype]AND [Grunntyp_1]!= [Grunntyp_2] AND [Grunntype]!= [Grunntyp_2]VB script, but I still get an error message:
  return 0enter image description here

I have a file with an attribute table with data in 3 columns, and would like to use field calculator to populate a 4th column. The data is integer numbers between 0 and 56. I want the new column to tell if the numbers in the 3 previous columns are identical or not. I would like the 4th column to state "3" if all 3 columns have the same number, "2" if 2 are the same, and "0" if none of the columns contain the same number. Does anyone know how to do this calculation?

I tried the following in Python:
def (Lik_grtyp):
if [Grunntype]== [Grunntyp_1] AND [Grunntyp_1]== [Grunntyp_2]:
return 3
elseif [Grunntyp_1]== [Grunntyp_2] OR[Grunntype] == [Grunntyp_1] OR [Grunntyp_2]== [Grunntype]:
return 2
elseif [Grunntyp_1]!=[Grunntype]AND [Grunntyp_1]!= [Grunntyp_2] AND [Grunntype]!= [Grunntyp_2]:
  return 0

I have a file with an attribute table with data in 3 columns, and would like to use field calculator to populate a 4th column. The data is integer numbers between 0 and 56. I want the new column to tell if the numbers in the 3 previous columns are identical or not. I would like the 4th column to state "3" if all 3 columns have the same number, "2" if 2 are the same, and "0" if none of the columns contain the same number. 

Does anyone know how to do this calculation?

I tried the following in VB script, but I still get an error message: enter image description here

added 374 characters in body
Source Link

I have a file with an attribute table with data in 3 columns, and would like to use field calculator to populate a 4th column. The data is integer numbers between 0 and 56. I want the new column to tell if the numbers in the 3 previous columns are identical or not. I would like the 4th column to state "3" if all 3 columns have the same number, "2" if 2 are the same, and "0" if none of the columns contain the same number. Does anyone know how to do this calculation?

I tried the following in Python:
def (Lik_grtyp):
if [Grunntype]== [Grunntyp_1] AND [Grunntyp_1]== [Grunntyp_2]:
return 3
elseif [Grunntyp_1]== [Grunntyp_2] OR[Grunntype] == [Grunntyp_1] OR [Grunntyp_2]== [Grunntype]:
return 2
elseif [Grunntyp_1]!=[Grunntype]AND [Grunntyp_1]!= [Grunntyp_2] AND [Grunntype]!= [Grunntyp_2]:
return 0

I have a file with an attribute table with data in 3 columns, and would like to use field calculator to populate a 4th column. The data is integer numbers between 0 and 56. I want the new column to tell if the numbers in the 3 previous columns are identical or not. I would like the 4th column to state "3" if all 3 columns have the same number, "2" if 2 are the same, and "0" if none of the columns contain the same number. Does anyone know how to do this calculation?

I have a file with an attribute table with data in 3 columns, and would like to use field calculator to populate a 4th column. The data is integer numbers between 0 and 56. I want the new column to tell if the numbers in the 3 previous columns are identical or not. I would like the 4th column to state "3" if all 3 columns have the same number, "2" if 2 are the same, and "0" if none of the columns contain the same number. Does anyone know how to do this calculation?

I tried the following in Python:
def (Lik_grtyp):
if [Grunntype]== [Grunntyp_1] AND [Grunntyp_1]== [Grunntyp_2]:
return 3
elseif [Grunntyp_1]== [Grunntyp_2] OR[Grunntype] == [Grunntyp_1] OR [Grunntyp_2]== [Grunntype]:
return 2
elseif [Grunntyp_1]!=[Grunntype]AND [Grunntyp_1]!= [Grunntyp_2] AND [Grunntype]!= [Grunntyp_2]:
return 0

Source Link
Loading