Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Partial sum of repeating fields

Featured Replies

  • Newbies

Hi all,

I have 2 repeating fields, Turnover last year & turnover this year, each with 12 repetitions.

I would like to compare the year to date turnover with same period last year.

EG If the current year has 3 months of turnover, the 3 first months have to be compared with the 3 first months of last year, and so on.

So using the COUNT function, I can determine that 3 months of this year have Turnover.

How can I dynamically make the sum of only the first 3 months of last year although all 12 repetitions cells have a value?

I was thinking of using the let function to avoid a lenghty calculation, but I don't grasp how to make the recursion...

Thanks for helping me out!

Recursive calculations are done through custom functions. You could define a custom function as:

SumRepetitions ( repeatingField ; maxRepetition ) =

GetRepetition ( repeatingField ; maxRepetition )
+
If ( maxRepetition > 1 ; SumRepetitions ( repeatingField ; maxRepetition - 1 ) )

and call it as =

SumRepetitions ( LastYear ; Count ( ThisYear ) )

 

Although with only 12 repetitions, you could do just =

Let ( [
n = Count ( ThisYear )
] ;
Sum ( 
If ( n ≥ 1 ; LastYear[1] ) ; 
If ( n ≥ 2 ; LastYear[2] ) ; 
If ( n ≥ 3 ; LastYear[3] ) ; 
If ( n ≥ 4 ; LastYear[4] ) ; 
If ( n ≥ 5 ; LastYear[5] ) ; 
If ( n ≥ 6 ; LastYear[6] ) ; 
If ( n ≥ 7 ; LastYear[7] ) ; 
If ( n ≥ 8 ; LastYear[8] ) ; 
If ( n ≥ 9 ; LastYear[9] ) ; 
If ( n ≥ 10 ; LastYear[10] ) ; 
If ( n ≥ 11 ; LastYear[11] ) ; 
If ( n ≥ 12 ; LastYear[12] )
)
)

 

Edited by comment

  • Author
  • Newbies

Great! Thanks!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.