4 Replies Latest reply on Jun 29, 2010 4:45 PM by philmodjunk

# How do I SUM totals of multiple fields?

### Title

How do I SUM totals of multiple fields?

### Post

When I try to sum the values in multiple fields it doesn't give me the correct result. Is there a proper structure for using such a function across more than one field? I find I have the same issue trying to calculate a standard deviation on data stored in multiple fields.

Here is an example of what I tried:

SUM(Table1::Field,Table2::Field)

Thanks!

• ###### 1. Re: How do I SUM totals of multiple fields?

That's the correct syntax, but you need to pay attention to the relationships linking your tables 1 and 2 to the table to the record where you define and evaluate the sum function.

Sum ( Table2::Field ) will total up all the values in Field for all related records in table 2 and that may not be what you expect here.

• ###### 2. Re: How do I SUM totals of multiple fields?

Sorry, I ment to include the example as follows:

SUM(Table1::Field1, Table1::Field2)

All of the fields are in the same table.

I get the correct sum if I focus on one field, but when I add the second field the results are inaccurate.

• ###### 3. Re: How do I SUM totals of multiple fields?

But what is the context of the Sum function?

Is this defined in a different table than Table1 or the same table?

If it's defined in a different table, then what I said in my previous post still applies. You'll note that in my last post, I only had one parameter: Sum ( Table1::Field1 ).

Likewise, if you put this in a script step, and the current layout refers to a different table, the same is true.

• ###### 4. Re: How do I SUM totals of multiple fields?

By the way, if you just want to add two fields, you can simply use Table1::field1 + Table1::field2