Sum Multiple Fields

4471
5
04-09-2019 11:34 AM
chadhickman
Occasional Contributor III

I have a table with over 4000 records and I would like to sum across three different field to get a cumulative score.I have attempted this multiple times in the past but I have been unsuccessful, does anyone know how to perform this function?

I have attached an example table, I would like to sum the three fields in red to the 'Final_Score' field.

Thanks

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

!a! + !b! + !c! 

make the answer field you want active in the table, launch Field calculate, select python parser, field names enclosed in ! marks, but if you actually select the field names in the calculator expression it will add them rather than my example a, b, c

But what did you try where it didn't work?

0 Kudos
chadhickman
Occasional Contributor III

I figured it out. 

1. I need to make the NULL value equal to zero

2. I had to select all the records.

Thanks for the reply

0 Kudos
DavidJeffers1
New Contributor II

I am looking to do a similar task but instead of three fields, I have 50. Any ideas on how to avoid typing in 50 versions of !attributeA! + !AttributeB! + ...?

Any input would be appreciated.

DaveJ

0 Kudos
Arne_Gelfert
Occasional Contributor III
import arcpy
fields = arcpy.ListFields(<your_feature_class_or_table>)
fieldnames = [field.name for field in fields]
lazyman_string = "!" + "+!".join(fieldnames) + "!"
‍‍‍‍‍‍‍‍‍
MōnoSimeone
Occasional Contributor II

How is this problem addressed in Pro when <null> is an appropriate value? Is there an 'else if' approach to summarizing across fields but excluding the <null> values? Part 2: How to calculate for the frequency of a 0 or 1 but not <null>?