Brian Dunning's FileMaker Custom Functions

SumRepetition ( Field ; Repetition ; RecordCount

Sums an individual repetition through a relationship.

  Average rating: 4.0 (41 votes) Log in to vote

Rob Poelking   Rob Poelking - Show more from this author
Excelisys, Inc.
http://excelisys.com

Share on Facebook Share on Twitter

  Sample input:
SumRepetition ( "R::field_nr" ; get ( calculationrepetitionnumber) ; count ( R::id ) )
  Sample output:
6

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

If you try to use SUM on a related repeating field, Filemaker will sum the entire contents of every repetition on a record and then for all related records when in fact you wanted the sum of repetition 2 for the related records.

 

Comments

Larry Goldman   Larry Goldman, Silicon Valley
Mar 18, 2014
Absolutely brilliant! A real FileMaker breakthrough!
 
helen   helen, aaa
Jun 2, 2014
I want example for sum with repetition field
 
Lon Cook   Lon Cook, San Francisco
Oct 24, 2014
RepetitionSum (
GetFieldName ( Extend ( R::field_nr ) )
; Get ( CalculationRepetitionNumber )
; Count ( Extend ( R::id ) )
)
 
Vaughan Bromfield   Vaughan Bromfield
Mar 18, 2016
Great function. I found that when summing a repeating field in a related table and there are no related records, I get the beach ball (OS X, FMP 14.0.5). I found adding a Case() to the CF to trap for no related records fixed the problem.

---

Case(

GetAsNumber( recordCount ) + 0 > 0 ;

Let(
[
r = repetition;
f = field ;
fr = GetField ( f & "[" & r & "]" );
cnt = recordCount
];
If (cnt > 0 ; GetNthRecord ( fr ; cnt ) + SumRepetition ( f ; r ; cnt - 1 ) ; 0 )
) // end Let

) // end Case
 
Rob   Rob, Cleveland, OH
Mar 19, 2016
Vaughan, its sounds like you have another issue going on there. That's exactly that the If(cnt>0... is supposed to take care of.
 

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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.