Of course I said use python. It's quick, easy, and reusable:
####################
# Input Parameters #
####################
inputTable = arcpy.GetParameterAsText(0)
CountFields = arcpy.GetParameterAsText(1)
VotedValues = arcpy.GetParameterAsText(2)
###################
# Local Variables #
###################
ElectionCountFieldName= "ElectionCount"
###################
# Logic #
###################
fields = arcpy.ListFields(inputTable)
for field in fields:
if field.name == ElectionCountFieldName:
arcpy.DeleteField_management(inputTable, ElectionCountFieldName)
break
del fields
arcpy.AddField_management(inputTable, ElectionCountFieldName, "TEXT")
rows = arcpy.UpdateCursor(inputTable)
splitVal = VotedValues.split(',')
for row in rows:
count = 0
for f in CountFields:
if str(row.getValue(f)) in splitVal:
count = count + 1
row.setValue(ElectionCountFieldName,str(count))
rows.updateRow(row)
del row, rows
arcpy.SetParameterAsText(3, inputTable)
where the inputTable is the table which contains the data you wish to sum up, CountFields is a collection of field names (multi-value object), and VotedValues is a comma separated string (value1,value2, etc...) that represents the values of a voter voted.
Now that the script is created, you need to create the toolbox in ArcCatalog or ArcMap:
Parameter | Name | Setup |
1 | Input Table/FC | Type: Feature Class or Table |
2 | Fields | Type: Field, Obtained From: Parameter 1, MultiValue: Yes |
3 | Voted Values | Type: String |
4 | Return Table/FC | Type: Table/FC, Direction: Output |
Enjoy and Happy GISing