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.

Does anyone know how you store data in a Calculation field's "Repetitions"?

Featured Replies

Does anyone know how you store data in a Calculation field's "Repetitions"? This isn't about referencing a separate repeating field or a relationship. I want all the action to happen in this one calculation field, but in different repetitions of this calculation field. 

Example: Calculation field name "CalcyCalc" with "Number of repetitions" in Calculation Options changed from 1 to 3. 

My calculation would be something like 

Case(month( Get ( CurrentDate ) )=1, *** repetition 1 of this calculation field CalcyCalc  = "Tom" *** )

;

Case(month( Get ( CurrentDate ) )=2, *** repetition 2 of this calculation field CalcyCalc  = "Dick" *** )

;

Case(month( Get ( CurrentDate ) )=3, *** repetition 3 of this calculation field CalcyCalc  = "Harry" *** )

-------

What I'm missing is the stuff set off by the triple asterisks. How does it work? It would be a simple way to do what I want without creating three separate fields. I'm going to put it on a layout with all the repetitions showing. 

With no way to specify where to put the results, all the repetitions in the Calc field display the same thing. 

IExample: Calculation field name "CalcyCalc" with "Number of repetitions" in Calculation Options changed from 1 to 3. 

My calculation would be something like 

Case(month( Get ( CurrentDate ) )=1, *** repetition 1 of this calculation field CalcyCalc  = "Tom" *** )

;

Case(month( Get ( CurrentDate ) )=2, *** repetition 2 of this calculation field CalcyCalc  = "Dick" *** )

;

Case(month( Get ( CurrentDate ) )=3, *** repetition 3 of this calculation field CalcyCalc  = "Harry" *** )

-------

​I don't understand this example. What is the actual result you're trying to achieve? A calculation field with three repetitions returns three separate results; in your case, there are 12 possible months - so you need to have a matrix of 12x3 possible results.

In addition to what Barb is saying; reconsider repeating fields when it comes to real data.  Repeating fields are useful but usually not when it comes to storing real data.  So instead of fixing the issue at hand, you may get more mileage from a more thorough re-examination of your tables / entities

  • Author

My example was poor. I appreciate the responses. Thank you bcooney for that helpful link explanation of using repeating fields -- definitely a bookmark. 

This documentation from Filemaker mentions Calculations with repetitions. The documentation says

Select Number of repetitions, then type the number of repetitions. 

http://www.filemaker.com/help/11/fmp/html/create_db.8.15.html 

Below is a test calculation. The result in a calculation field with 1 repetition  is "Q". The result in a calculation field with 10 repetitions is a "Q" in each repetition. 

Is it possible to specify a "Q" in the first calculation field repetition, an "X" in the second calculation field repetition, and so on? What would the function be? 

This must be easy if only I could explain what I want to know better.

_=_=_=_=_=_=_=_=_=_=_=_=_=_=_

Let ( 

$firstnumber  =   6;  // placeholder for test purposes only
$secondnumber  =  6;  // placeholder for test purposes only
$bullet=  "Q"   ;
$bulletmatch = Case ( $firstnumber = $secondnumber ; $bullet)

 ]; // end variables

// start calc

$bulletmatch

// end calc

) // end let

 

 

Edited by RoundtableSam
changed "no repetitions" to "1 repetition

Is it possible to specify a "Q" in the first calculation field repetition, an "X" in the second calculation field repetition, and so on? What would the function be?

​So we still have no idea what you want to do, but you should look at Get ( CalculationRepetitionNumber );

Choose ( Get ( CalculationRepetitionNumber ) - 1 ;
  "Q" ;
  "X" ;
  …
)

or

GetValue ( "Q¶X¶…" ; Get ( CalculationRepetitionNumber ) )

Is it possible to specify a "Q" in the first calculation field repetition, an "X" in the second calculation field repetition, and so on?

​Yes, it is possible - but you might get better answers if you explain the purpose of having such calculation. At this point, it seems like the best solution would be to type "Q", "X", etc. directly onto the layout.

Edited by comment

  • Author

Hi, eos.

Not sure if this explanation will help because my main goal is to learn how calculation repetitions work rather than how to solve a particular problem. Im a long-time hobbyist, hence the gaps in my knowledge. I thank you all for taking the time to answer. 

Is there a Set( CalculationRepetitionNumber ) function similar to the set field script step?

Define fields > "new field name" > Type: Calculation > Options… > Number of repetitions. The default is "1".

This morning I was experimenting with highlighting a row of buttons based on a month or day of the week or some other easy to calculate trigger. Lots of other things would work, such as conditional formatting or multiple fields or multiple scripts, but they all have problems such as hard coding or other things.

Before today, I'd never noticed the repetition option on calculation fields. It seemed like that might be a cool way to make a highlight since it would just be one field with a calculation that would result in a bullet "•" in the desired location. One field with a number of repetitions is easy to layout and easy to change if needed. If it would work.

I can't find any documentation that would tell me how repetition of calculation fields work. There is endless documentation on how to use repeating fields IN calculations, but not how to fill repetitions OF calculation fields. My example calc puts the same data in all repetitions. 

Is there a Set( CalculationRepetitionNumber ) function similar to the set field script step?

​No, but there's the Get ( CalculationRepetitionNumber ) function that you can use in order to control the result of each individual repetition (as shown in the example given by eos).

 

my main goal is to learn how calculation repetitions work rather than how to solve a particular problem.

​Perhaps this might be helpful:

  • Author

Hi, comment. 

I'd love to look at it. ​The attachment link at "Poor man's recursive function" post didn't download. I'll try again later. Thank you. 

 

The attachment link at "Poor man's recursive function" post didn't download.

​Report it here:

Edited by comment

  • Author

Eos, comment, Get ( CalculationRepetitionNumber ) worked perfectly and elegantly. 

Thank you, and thank you for your patience. 

Below is the test calc. 

Let ( 

$repeater=Get ( CalculationRepetitionNumber ); 
$number= 1; // for actual, use calculated value instead of static value
$bullet="•";
$bulletmatch=Case($repeater=$number; $bullet);

$end=0 //last variable is not followed by semi-colon

 ]; // end variables

// start calc

$bulletmatch 

// end calc

) // end let

Note:

Using $variables in a Let()function is not a good idea - unless you actually want those variables to persist after the calculation is evaluated (until you close the file).

  • Author

Note:

Using $variables in a Let()function is not a good idea - unless you actually want those variables to persist after the calculation is evaluated (until you close the file).

​Are $$variables okay?

​Are $$variables okay?

No you should use unprefixed variables, e.g.

Let ( [
i = Get ( CalculationRepetitionNumber ) ;
text = Extend ( Textfield )
] ; 
Middle ( text ; i ; 1 )
) 

The scope of these variables does not exceed their parent Let() function. The scope of local $variables (single $) is the current script. The scope of global $$variables is the current session. See also  http://fmforums.com/forums/topic/90920-retrieve-variables-set-in-another-script-you-performed/?do=findComment&comment=417743 and http://fmforums.com/forums/topic/94863-how-can-i-use-the-let-function-to-set-a-localvariable/?do=findComment&comment=434320.

 

  • Author

No you should use unprefixed variables, e.g.

Let ( [
i = Get ( CalculationRepetitionNumber ) ;
text = Extend ( Textfield )
] ; 
Middle ( text ; i ; 1 )
) 

The scope of these variables does not exceed their parent Let() function. The scope of local $variables (single $) is the current script. The scope of global $$variables is the current session. See also  http://fmforums.com/forums/topic/90920-retrieve-variables-set-in-another-script-you-performed/?do=findComment&comment=417743 and http://fmforums.com/forums/topic/94863-how-can-i-use-the-let-function-to-set-a-localvariable/?do=findComment&comment=434320.

 

​Like I said, huge gaps in my knowledge. This is very helpful. Thanks, again, comment. 

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.