Skip 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.

Field Calculation Recursion Help

Featured Replies

I am trying to design a recursive field that will give me an IRR of an investment.

To calculate IRR, I have to understand recursion.

As a guide, I downloaded this very good example.... but do not understand it,

Let(
$i = $i + 1 ;
Middle( "abcdefghkjilmnopqrstuvwxyz" ; $i ; 1 ) & If ( $i < EndLoop ; ¶ & Test ; Let( $i = "" ; "" ) )
)

Can someone explain to me was "Test" does?  I feel silly... but can find no documentation on it.

And what does the "Let( $i = "" ; "" )" do?

Thanks,

#1 Solved... Test is the field name... hence the recursion

FileMaker field calculations cannot be recursive, but they can use a custom function (CF), which can be.

In your example it's not exactly clear, but I believe Test would be the name of the CF, and EndLoop would be a parameter of the CF. As such, there's an error, because where it says "Test" after the paragraph mark it's missing its parameter. It should be:

Let(
$i = $i + 1 ;
Middle( "abcdefghkjilmnopqrstuvwxyz" ; $i ; 1 ) & 
If ( $i < EndLoop ;  & Test(EndLoop)  ; Let( $i = "" ; "" ) )
)

If you call the CF like this:

Test(3)

... the output will be:

a
b
c

As it runs, it increments the counter $i; grabs the $i letter from the string, and then if $i is less than EndLoop -- 3 in this case -- it does it again, by calling itself, which is called recursion. Once $i reaches 4, it goes to the end of the If() function -- Let( $i = "" ; "" ) -- what this does is reset the counter $i and return a null result -- because a Let function has to return something, even if it's only null -- and since it does NOT call itself, the calculation is done. It's always important that a recursive function has some kind of logic like that to tell it when to stop.

Hope that helps.

PS: you don't have to use a recursive custom function, you could try scripting it.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.