Cognito Forms – Calculating Number of Selected Checkboxes in Repeating Section

cognito-forms

I'd like to give a discount based on the number of camp sessions signed up for in a repeating section but can't figure out the formula for doing that. Help?

In the repeating section called "Camper Information" I have a choice box called "sessions":

Sessions

July 1-5 $225

July 7-12 $225

July 14-19 $225

July 21-26 $225

I'm trying to make a calculation that will do:

number of sessions > 1 but < 3 gives a 5% discount

number of sessions > 4 gives a 10% discount

https://www.cognitoforms.com/Edenacres1/SummerOutdoorsSignUpForm

Best Answer

Calculations for Repeating Sections in Cognito Forms, allow you to easily filter and total lists of structured information.

You can find detailed documentation for calculations involving repeating sections here: https://www.cognitoforms.com/support/51/calculations/repeating-sectionstables

For your specific example, the following calculation will automatically calculate the number of selected sessions across all repeating sections:

=CamperInformation.Sum(Sessions.Count)

You can then use this inside a discount calculation for a Price field outside of the repeating section as follows:

=(
   if CamperInformation.Sum(Sessions.Count) > 3 then -0.1 
   else if CamperInformation.Sum(Sessions.Count) > 1 then -0.05 
   else 0
 ) *
 CamperInformation.Sum(Sessions_Amount)