Cognito-forms – How to calculate sub totals for repeating sections in Cognito Forms

cognito-forms

Is there a way of calculating the sub totals of each repeating section? I am trying to construct an invoicing form for our freelance workers. The repeating sections are very useful so that only the relevant parts are viewable to the form filler, but although I can create an invoice sub total for each section, I cannot find a way to calculate an invoice total at the end.

Do you have any suggestions?

Best Answer

There are a couple of ways to handle calculating subtotals for repeating sections:

  1. If the form represents a true invoice and the subtotals represent money and nothing else, you can set the form up to use the built in payment features of Cognito Forms. When you mark fields as Collect Payment, they will automatically appear on receipt/invoice grouped by repeating section item. Choice, Currency, Yes/No and Price fields can all appear on this "invoice" and the Price field gives you complete control with the ability to calculate both the amounts and the description of each line item if you need this power. In this case you would not be collecting payment from them, so mark the form via Payment Settings as never requiring payment.

enter image description here

  1. The other option is to use the powerful calculation capabilities in Cognito Forms to quickly calculate the subtotals. In the example above, you could add a Calculation field at the bottom of the form and use a calculation like =MyOrder.Sum(ItemTotal) or even =MyOrder.Sum(Product_Amount * Quantity) to calculate the total for the My Order repeating section. Remember set the Type to Currency for the Calculation field so it will be formatted correctly and allow you to use the value of this field in other calculations. You can learn more about these capabilities in our help documentation at: https://www.cognitoforms.com/support/51/calculations/repeating-sectionstables. Take a look at the section on Working with Repeating Sections.

Please mark this as the answer if it helps you make this work, or add a comment if it is not quite what you were looking for.