Brian Dunning's FileMaker Custom Functions

TypeSumField ( TypeField ; Type ; SumField ; Counter )

Sum a numeric field for records where another field matches input value.

  Average rating: 4.2 (43 votes) Log in to vote

Bruce Robertson   Bruce Robertson

Share on Facebook Share on Twitter

  Sample input:
TypeSumField(
Invoice_Items::Category;
"Labor";
Invoice_Items::Total;
count(Invoice_Items::InvoiceID)
)
  Sample output:
325.50

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

Sum a numeric field specified by SumField across multiple records, for records where field specified as TypeField matches a value such as "Labor" or "Parts". If you enter "Total" as the type then you get a total for all records.

Another example:
Let( RC = count(Invoice_Items::InvoiceID);
List(
"Labor: " & TypeSumField(
Invoice_Items::Category;
"Labor";
Invoice_Items::Total;
RC
);
"Parts: " & TypeSumField(
Invoice_Items::Category;
"Parts";
Invoice_Items::Total;
RC
);
"Total: " & TypeSumField(
Invoice_Items::Category;
"Labor";
Invoice_Items::Total;
RC
)
)

 

Comments

Chris   Chris, Happyville
Apr 22, 2011
Hello, thanks for providing this custom function. However, I don't understand what the counter is for?

How can I use the script without providing a counter?
 
Bruce Robertson   Bruce Robertson
Mar 4, 2012
As written, you can't use it without a counter. The instructions and example both show how to use the counter; which is either the count of related records or found count depending on how you are using the function. The function collects data by capturing data from the last record and iterating down to the first.

Bruce
 
Jerome   Jerome, Milan
Oct 29, 2014
Using the function, it runs properly at first.
However, havgin experimented with it, gradually adding groups of records, it stops adding to the sums, somewhere between 91 and 113 records.
 

Log in to post comments.

 

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

Under construction. Email me your wish list for improvements.