# ListSum ( myList )

Add up a list of numbers

Average rating: 4.1 (53 votes) Log in to vote

Tom Fitch http://www.fitchandfitch.com |

2

3

Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This replaces the list's carriage returns with semicolons so that the Sum function can be used, e.g. Sum(1;2;3). Non-recursive. Works with negative numbers.

Inspired by comments on the SUMLIST function.

Original from May 2011

Updated Aug. 2013

Now works with single (or empty) lists, per Mr. Cheang's comment below. Thanks to him and also to Agnès for pointing out that this only works for up to 1000 values (see comments below). It also doesn't do any other error checking such as if you feed in a bunch of blank lines or other nonsense.

## Comments

Agnès, France May 25, 2011 |
||

Hello, Be carreful with this type of calculation using Evaluate ( Max or Evaluate ( Min or Evaluate ( Sum (...) The result will be "?" if you have 1001 values in your list |
||

Tom Fitch May 25, 2011 |
||

Thanks, Agnès! You're correct. I wasn't able to locate any documentation of this limitation, and I'd like to know more about it. Can you point me to a reference? | ||

Agnès, France May 26, 2011 |
||

I have no reference for this, just the tests I did with Evaluate and calculations in FileMaker. There is no problem, usually we use this calculation on small lists, until the day where. this is what happened to me. to test : Let ([ myList = Customlist ( 1 ; nbr ; "[n]" ) ; it = Substitute( myList ; ¶ ; ";" ) ; Su = Substitute( myList ; ¶ ; "+" ) ]; Evaluate( "Sum(" & it & ")" ) // Limit nbr : 1000 & ¶ & Evaluate( Su ) // limit nbr : 5238 ) Let ( $Count = 0 ; Customlist ( 1 ; nbr ; "Let ([ $Count = $Count + [n] ]; """" )" ) & $Count ) // limit nbr : 500000 |
||

Tom Fitch May 26, 2011 |
||

Interesting. Thanks again for the info. | ||

Bernard Cheang, Singapore Dec 29, 2011 |
||

It also doesn't work if you only have one item in the list. You need to do a check and append a "0" to the supplied list if there is only one item. | ||

Kostas Papavasileiou, Athens Aug 21, 2013 |
||

I m trying to sum up the Grand Totals of Time Billings at the Time Billings Layout. I m pretty novice. What's the function to add in the DB, please? having lost already ... Thank you very much ... | ||

Tom Fitch Aug 21, 2013 |
||

Mr. P, this isn't really a support site (and I don't understand your question). I suggest fmforums.com or filemaker.com/technet/ |
||

Kostas Papavasileiou, Athens Aug 22, 2013 |
||

Thank you very much! I will do so! Didn't see that was not right on my behalf to ask. Thakn you again. | ||

Bill, Portland, Oregon Sep 8, 2013 |
||

Thanks, Tom---just what I was looking for today. 67% Shotgun |
||

Mike Gallagher, Ft Lauderdale Feb 5, 2014 |
||

Thanks as well... simplify the first argument to the following: myList = myList and it will work for standard deviation as well, e.g.: result = Evaluate( "STDEV(" & it & ")" ) |
||

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.