Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 7458 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I normally avoid repeating fields, but they can be handy in certain situations. Is it possible to assign (in Specify Calculation) each element of a repeating field (of calculation type) to a different calculation? For example, field_ru[1] = 1, field_ru[2] = 5, etc.

Posted

Forget using static values; in my example I should have used fields which update dynamically. So, for example, field_ru[1] = amount[1], field_ru[2] = amount[1] + amount[2], where the amount repeating field (each element) is changing.

Posted

Choose( Get(CalculationRepetitionNumber) - 1; Amount; GetRepetition( Amount; 1 ) + Amount )

Posted

It's very clear to me now that using this method enables arrays (i.e., repeating fields) to be used all over the place in FileMaker. Here's a snippet of code which uses Choose, Get, CalculationRepetitionNumber and Case:

za_amount_le30_ru =

Choose ( Get ( CalculationRepetitionNumber ) ;

0 ;

Case ( za_dy_ru[1] <= 30 and za_pm_u < 0 ; za_iad_ru[1] ;

za_dy_ru[1] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_iad_ru[1] ) ; za_iad_ru[1] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[2] <= 30 and za_pm_u >= 0 and za_pm_u <= za_iad_ru[1] ; za_iad_ru[2] ;

za_dy_ru[2] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[2] ) ; za_isum_ru[2] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[3] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[2] ) ; za_iad_ru[3] ;

za_dy_ru[3] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[3] ) ; za_isum_ru[3] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[4] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[3] ) ; za_iad_ru[4] ;

za_dy_ru[4] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[4] ) ; za_isum_ru[4] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[5] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[4] ) ; za_iad_ru[5] ;

za_dy_ru[5] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[5] ) ; za_isum_ru[5] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[6] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[5] ) ; za_iad_ru[6] ;

za_dy_ru[6] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[6] ) ; za_isum_ru[6] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[7] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[6] ) ; za_iad_ru[7] ;

za_dy_ru[7] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[7] ) ; za_isum_ru[7] - za_pm_u ;

0 ) ;

Case ( za_dy_ru[8] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[7] ) ; za_iad_ru[8] ;

za_dy_ru[8] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[8]) ; za_isum_ru[8] - za_pm_u;

0 ) ;

Case ( za_dy_ru[9] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[8] ) ; za_iad_ru[9] ;

za_dy_ru[9] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[9] ) ; za_isum_ru[9] - za_pm_u;

0 ) ;

Case ( za_dy_ru[10] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[9] ) ; za_iad_ru[10] ;

za_dy_ru[10] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[10] ) ; za_isum_ru[10] - za_pm_u;

0 ) ;

Case ( za_dy_ru[11] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[10] ) ; za_iad_ru[11] ;

za_dy_ru[11] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[11] ) ; za_isum_ru[11] - za_pm_u;

0 ) ;

Case ( za_dy_ru[12] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[11] ) ; za_iad_ru[12] ;

za_dy_ru[12] <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[12] ) ; za_isum_ru[12] - za_pm_u;

0 ) ;

)

Edit: Fixed HTML less than/greater than or equal to symbols -Queue-

Posted

It seems to me you can simplify this greatly. Something like

Let( R = Get(CalculationRepetitionNumber);

Case( R = 1;

Case ( za_dy_ru <= 30 and za_pm_u < 0; za_iad_ru;

za_dy_ru <= 30 and za_pm_u >= 0 and za_pm_u <= za_iad_ru; za_iad_ru - za_pm_u;

0 );

Case( za_dy_ru <= 30 and za_pm_u >= 0 and za_pm_u <= ( za_isum_ru[R-1] ); za_iad_ru;

za_dy_ru <= 30 and za_pm_u >= 0 and za_pm_u <= za_isum_ru; za_isum_ru - za_pm_u;

0 )

)

Note that if za_pm_u is a non-repeating field, you should use Extend(za_pm_u) when referencing it in a repeating field calculation or it will only work for the first repetition. Also, if you are calculating the nth repetition, then field[n] = n, when n is another repeating field.

Posted

Thanks very much. Here is the revised snippet of code, with the Extend function on za_pm_u.

Let ( [ R = Get ( CalculationRepetitionNumber ) ] ;

Case ( R = 1 ;

Case ( za_dy_ru <= 30 and Extend ( za_pm_u ) < 0 ; za_iad_ru ;

za_dy_ru <= 30 and Extend ( za_pm_u ) >= 0 and Extend ( za_pm_u ) <= za_iad_ru ; za_iad_ru - Extend ( za_pm_u ) ;

0 ) ;

Case ( za_dy_ru <= 30 and Extend ( za_pm_u ) >= 0 and Extend (za_pm_u ) <= ( za_isum_ru[R-1] ) ; za_iad_ru ;

za_dy_ru <= 30 and Extend ( za_pm_u ) >= 0 and Extend (za_pm_u ) <= za_isum_ru ; za_isum_ru - Extend ( za_pm_u ) ;

0 )

)

)

This is very elegant and very fast. As for my field naming convention, I use the "FileMaker Pro Development Standards" by Core Solutions, Inc. So, za means "developer field for user calculation, u = unstored, and r = repeating field.

This topic is 7458 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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