One of the unique features of Cognito Forms is the ability to capture repeating data on forms, such as a variable list of emergency contacts or a list of job references. To capture repeating data, just add a Repeating Section or Table to your form, and add the fields you want to capture in the repeating section.
The following extensive example demonstrates how to create an event signup sheet and calculate a variety of things based on who is attending:
This registration form allows families to sign up for a conference hosted at a resort hotel. One registration form allows multiple adult or child attendees to sign up, select optional t-shirt sizes, register for golf to kick off the conference, and prepay for discounted arcade money to use throughout the resort. Here is a detailed breakdown of all of the calculations used to implement this form, highlighting the ease with which calculations can be created for repeating data using Cognito:
|Number of Adults|
|Adult Registration Fee|
|Number of Children|
|Child Registration Fee|
|Number of T-Shirts|
|Number Playing Golf On Friday|
|Golf Registration Fee|
|Total Arcade Bucks|
|Arcade Bucks Fee|
|Total Registration Fee|
The above example makes heavy use of Count and Sum functions for repeating data, but there are a number of additional functions supported for this type of data:
| ||Yes/No||Determines whether all items of a repeating section or table satisfy a condition.|
| ||Yes/No||Determines whether a repeating section or table contains any items.|
| ||Yes/No||Determines whether any items in a repeating section or table satisfy a condition.|
| ||Number||Computes the average of a numeric calculation for each item in a repeating section or table.|
| ||Number||Returns the number of items in a repeating section or table.|
| ||Number||Returns the number of items in a repeating section or table that satisfy a condition.|
| ||Item||Returns the first item in a repeating section or table.|
| ||Item||Returns the first item in a repeating section or table that satisfies a condition.|
| ||Item||Returns the last item in a repeating section or table.|
| ||Item||Returns the last item in a repeating section or table that satisfies a condition.|
| ||Item||Returns a specific item in a repeating section or table as denoted by the item number.|
| ||Number||Computes the maximum value of a numeric calculation for all items in a repeating section or table.|
| ||Number||Computes the minimum value of a numeric calculation for all items in a repeating section or table.|
| ||Number||Computes the summation of a numeric calculation for all items in a repeating section or table.|
| ||List||Filters the items in a repeating section or table based on a condition.|
Referencing repeating data
Because repeating sections can collect a potentially unlimited amount of data, the syntax for targeting field data is slightly different.
Referencing data from all repeating items
To reference repeating data:
- Add a Calculation field to your form (outside of your repeating section). If this data is just for internal use, make sure to set the Show This Field option to Internal.
- For your expression, denote the title of your repeating section, followed by the .Select function and your field name:
- Now, your Calculation field will compile every name inputted into your repeating section.
Referencing data from specific repeating items
The above example targets data from every repeating section item. To reference field data from just one specific repeating item:
- Add a Calculation field, or the appropriate field type for the data that you’re collecting. Ex: If you want to reference data from an Email field, add an Email field outside of your repeating section.
- For your calculation or default value expression, denote the title of your repeating section, followed by the .Where function to the repeating item you want to reference, and the .Select function to reference the field itself:
=RepeatingSection.Where(ItemNumber = 1).Select(Email)
- Now, only the email field in the first repeating entry will be targeted.
Referencing and replicating data from the first repeating item
You can reference a field in the first repeating item, and default subsequent repeating item fields to the same value:
- Select the field that you want to default to in every repeating item.
- Set the Default Value to:
=if ItemNumber = 1 or Text != null then Text else Form.RepeatingSection.First().Text
- Make sure to replace ‘Text’ with the name of your field, and ‘Repeating Section’ with the name of the repeating section on your form.