# SumRepetition ( Field ; Repetition ; RecordCount

Sums an individual repetition through a relationship.

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.

 Larry Goldman, Silicon ValleyMar 18, 2014 Absolutely brilliant! A real FileMaker breakthrough!
 helen, aaaJun 2, 2014 I want example for sum with repetition field
 Lon Cook, San FranciscoOct 24, 2014 RepetitionSum ( GetFieldName ( Extend ( R::field_nr ) ) ; Get ( CalculationRepetitionNumber ) ; Count ( Extend ( R::id ) ) )
 Vaughan BromfieldMar 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, Monk MediaMar 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.

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 16 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: