Cognito Forms logo

Repeating sections/Tables

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 (coming soon) 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:

Calculated Field

Calculation

Number of Adults

=Attendees.Count(AdultOrChild = "Adult")
 

Adult Registration Fee

=NumberOfAdults * 150
 

Number of Children

=Attendees.Count(AdultOrChild = "Child")
 

Child Registration Fee

=Math.Max(NumberOfChildren - NumberOfAdults, 0) * 25

or

=NumberOfChildren > NumberOfAdults ? (NumberOfChildren – NumberOfAdults) * 25 : 0
 

Number of T-Shirts

=Attendees.Count(TShirt != "None")
 

T-Shirt Fee

=Attendees.Count(TShirt.Contains("Youth")) * 15 + Attendees.Count(TShirt.Contains("Adult")) * 20
 

Number Playing Golf On Friday

=Attendees.Count(GolfOnFriday)
 

Golf Registration Fee

=NumberPlayingGolfOnFriday * 65
 

Total Arcade Bucks

=Attendees.Sum(ArcadeBucks)
 

Arcade Bucks Fee

=TotalArcadeBucks * 0.75
 

Total Registration Fee

=AdultRegistrationFee + ChildRegistrationFee + TShirtFee + GolfRegistrationFee + ArcadeBucksFee
 

 

This 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:

Returns

Name

Description

Yes/No

All(Yes/No Calculation)

Determines whether all items of a repeating section or table satisfy a condition.

Yes/No

Any()

Determines whether a repeating section or table contains any items.

Yes/No

Any(Yes/No Calculation)

Determines whether any items in a repeating section or table satisfy a condition.

Number

Average(Numeric Calculation)

Computes the average of a numeric calculation for each item in a repeating section or table.

Number

Count()

Returns the number of items in a repeating section or table.

Number

Count(Yes/No Calculation)

Returns the number of items in a repeating section or table that satisfy a condition.

Item

First()

Returns the first item in a repeating section or table.

Item

First(Yes/No Calculation)

Returns the first item in a repeating section or table that satisfies a condition.

Item

Last()

Returns the last item in a repeating section or table.

Item

Last(Yes/No Calculation)

Returns the last item in a repeating section or table that satisfies a condition.

Item Where(Item Number = 1) Returns a specific item in a repeating section or table as denoted by the item number.

Number

Max(Numeric Calculation)

Computes the maximum value of a numeric calculation for all items in a repeating section or table.

Number

Min(Numeric Calculation)

Computes the minimum value of a numeric calculation for all items in a repeating section or table.

Number

Sum(Numeric Calculation)

Computes the summation of a numeric calculation for all items in a repeating section or table.

List

Where(Yes/No Calculation)

Filters the items in a repeating section or table based on a condition.

 

Because repeating sections can collect a potentially unlimited amount of data, the syntax for targeting field data is slightly different.

Referencing fields

Let's say that you have a Name field in your repeating section, and you want to reference all of the inputted Names:

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

2. Use the following expression as your calculation:

=RepeatingSection.Select(Name)

Here, we're just denoting the title of your repeating section ("Repeating Section"), followed by the .Select function and your Name field ("Name").

3. Now, your Calculation field will compile a list of every name inputted into your repeating section:

Referencing repeating items

The above example targets data from a specific field in every repeating section item. But what if you want to target a field from just one specific item? To do this:

1. Add a Calculation field, or whatever field type corresponds with the data that you're collecting. If you wanted to reference data from an Email field, for example, add an Email field outside of your repeating section

2. Use the following expression as your calculation or default value:

=RepeatingSection.Where(ItemNumber = 1).Select(Email)

Here, we're using the .Where function to specify which repeating section item we want to target (in this case, #1).

3. Now, only the email field in the first repeating entry will be targeted.

Printable View