Why do people do this?

neileg

AWF VIP
Local time
Today, 18:49
Joined
Dec 4, 2002
Messages
5,970
Reading a post on here has prompted me to post this.

It baffles me why lots of users chuck in a spurious Sum() in their expressions. One of my colleagues uses this form all the time in Excel, too.

If you write an expression A+B+C this calculates the sum. If you embrace this with Sum(), i.e. Sum(A+B+C) you are summing what is inside the brackets, which has already been evaluated as a single number, since Access (and Excel) start from the innermost calculation.

Now most of the time, this is simply a redundant operation and does not affect the value, but it can in certain circumstances result in an unitended outcome. It is therefore better practice not to do this.

The proper syntax for the Sum() function is of course Sum(A,B,C).
 
Don't use the Sum much in access but in excel it replaces the need to include all the cells in your caculation eg:
if in cell A1 you put =SUM(A2:A100) then A1 would read the total of the cells A2 to A100 ( A1 + A2 + A3 etc)
Dave
 
Yeah, Dave I know that. It's just the combination of Sum() and the A+B+C... that does my head in!
 
Think of our understanding as others misunderstanding.
Once enlightened, they should realize the sense in what you are trying to covey :)
Dave
 
Ditto Pat, I think that kind of clarifies it. I was going to say the same. :)
 
Aww, I was so looking forward to your explanation Vass

Looks like I will have to re-read Pat's. ;)
 

Users who are viewing this thread

Back
Top Bottom