TotalList (theList)
Rate this function: Average rating: 3.8 (10 votes) Discuss this Custom Function
Geoff Wells, DataIsland Software LLC
http://www.dataisland.com
Add together all numbers in a text string
Sample Input:
|
Sample Output:
|
Description:
This function will total all the numbers contained within a text string and separated by a space or carriage return. Letters and punctuation are ignored. Input can be a text field or a function (such as Fibonacci) that outputs a list of numbers.
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
|
Newest Custom Functions:
| 1. |
list.intersect (listA; listB) |
| |
(Mon, May 14, 12:43pm) |
| 2. |
WeekStart ( weekOfYear ; year ) |
| |
(Sat, May 12, 8:42am) |
| 3. |
PercentToWords (FIELD) |
| |
(Thu, May 10, 3:16pm) |
| 4. |
PercentToText (FIELD) |
| |
(Thu, May 10, 2:37pm) |
| 5. |
StripReserved( text ) |
| |
(Wed, May 02, 6:05pm) |
| 6. |
ListBaseTables |
| |
(Wed, May 02, 3:48pm) |
| 7. |
ValidEmail( theEmail ) |
| |
(Wed, May 02, 7:27am) |
| 8. |
UltraDate (Text; LongDate_or_DateDigit) |
| |
(Wed, May 02, 6:07am) |
 |
|
This is a great function - used in conjunction with FoundList(), it eliminates the need for Summary fields if you just need the total of a found set of numbers.
However, by using the Word functions, it's dependent on FM's word separators...which, unfortunately in this case, includes the period. That means it will not correctly interpret numbers between 0 and 1 (.19 will be treated as 19, for example).
If you use Value functions, it corrects this problem. I realize that breaks the intent of being able to add up space-separated numbers, but thought it might be helpful to know:
Let ( Total = 0 ;
If (
ValueCount ( theList) > 1;
Total + GetAsNumber ( ( LeftValues ( theList; 1 ) ) ) +
TotalList ( RightValues ( theList; ValueCount( theList ) - 1) );
Total + GetAsNumber ( ( LeftValues ( theList; 1 ) ) )
)
)
Andy Frazier, Salem, NH
November 18, 2009 8:00am