--- title: "How Do I Sum Values Across Multiple Instances of a Subform?" slug: "how-do-i-sum-values-across-multiple-instances-of-a-subform" updated: 2026-09-28T06:23:30Z published: 2026-09-28T06:23:30Z canonical: "help.quickbase.com/how-do-i-sum-values-across-multiple-instances-of-a-subform" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.quickbase.com/llms.txt > Use this file to discover all available pages before exploring further. # How Do I Sum Values Across Multiple Instances of a Subform? ### Overview A major benefit of [**subforms**](/fastfield/docs/creating-and-using-subforms) is that they can be repeated within the main form. You can ask users to input data for one item, for example, and simply have them repeat that section as many times as needed depending on how many items they have. If you're asking users to input a **value** for each subform instance (e.g., quantity, price) you can have the form calculate the **sum** of all values across the repeated instances. For example, let's say your **main form** is an order form and it has a **subform** that contains a drop-down product list with: - An assigned **price** for each item on the list - A field to indicate the **quantity** of the items that will be purchased. Users can select an item and its quantity from the drop-down list (e.g., *2 apples*). They can then repeat the subform and choose a new item/quantity (e.g., *1 banana*), and repeat again as needed. With each selection, the total price (**sum**) would automatically calculate on the form (e.g., *$4.99*). This can be set up in a few simple steps in the Form Builder. > [!NOTE] > **Note** > > *This article assumes you have a general understanding of how to use the Calculation field and subforms. An advanced understanding of scripting field rules and skip logic is also beneficial, although the process is fairly simple after accomplishing it once.* ## How to sum values of multiple subform instances ### Set up your subform In the following instructions, we'll walk you through how to set up a basic calculation of quantity and price to get the sub-total. You may adjust the formula to any type of calculation to meet your needs (averages, percentages, if/then statements, variables, etc.). 1. Create or open an existing **subform** in the **Form Builder** (learn [how to create a subform](/fastfield/docs/creating-and-using-subforms)). 2. Add the **List** field to create a list (if you don't have one already). 3. Select **Add List Items** from the menu on the right to create your list. 4. Select **Advanced** and make sure your list has an assigned **score** for each item. - In the example below, our subform contains a product list of fruit (apple, lemon, watermelon, orange) with scores (in the red box) associated with those selections ![Subform product list with assigned score values for each item](https://cdn.document360.io/dd260e4e-10bb-4b66-8fb3-5504c272b904/Images/Documentation/115003453111?sv=2026-02-06&spr=https&st=2026-10-30T07%3A21%3A10Z&se=2026-10-30T08%3A21%3A10Z&sr=c&sp=r&sig=DUFGyKYHplZxqRLHScdycO9l4NJmUsj%2FRKN3OI6Z%2FWs%3D) 5. Add a **Numeric** field to your subform. - Our example above is labeled *Quantity* because we will have users enter the quantity of the product they wish to purchase. 6. Add a **Calculation** field to your subform. - Our example above is labeled *Sub Total* because we will use it to calculate the sum of the quantity (Numeric fields). 7. Select **Add** **Calculation** in the **Calculation Settings** menu. 8. In the **Calculation Formula** box, multiply the **score** of your list by the **Numeric** field (quantity) to get the sub-total. To set up this calculation: - Select the fields you wish to calculate from the list of fields on the left side of the window. This will automatically add them to the formula box. - Put a ***** symbol between the two field keys to multiply them. - Put a **#** symbol in front of the list field key (ours is *$listpicker_1$*). This lets the code know to calculate the score of the list selections instead of the value. 9. **Save** and **publish** your subform. - We recommend testing your subform on your device to make sure that the calculation displays and computes how you want it. ![Calculation Formula editor showing the subform score multiplication formula](https://cdn.document360.io/dd260e4e-10bb-4b66-8fb3-5504c272b904/Images/Documentation/image(104).png?sv=2026-02-06&spr=https&st=2026-10-30T07%3A21%3A10Z&se=2026-10-30T08%3A21%3A10Z&sr=c&sp=r&sig=DUFGyKYHplZxqRLHScdycO9l4NJmUsj%2FRKN3OI6Z%2FWs%3D) ### Set up your main form 1. Open your **main form** in the Form Builder and add a **Sub-Form** field. 2. Select your **subform** from the drop-down list on the right and select **Allow Multiple Sub-Form Instances**. 3. Add a **Calculation** field to your **main form**. - This calculation field will contain a formula that pulls the values across multiple instances of your subform and total them. 4. Select **Add Calculation** under the **Calculation Settings** menu on the right. 5. In the **Calculation Formula** box, enter this formula: **sumSubform($subform$, 'fieldkey')** 6. Replace **$subform$** with your subform's field key (our is *subform_3*). ![sumSubform formula entered in the Calculation Formula box](https://cdn.document360.io/dd260e4e-10bb-4b66-8fb3-5504c272b904/Images/Documentation/14152770443405?sv=2026-02-06&spr=https&st=2026-10-30T07%3A21%3A10Z&se=2026-10-30T08%3A21%3A10Z&sr=c&sp=r&sig=DUFGyKYHplZxqRLHScdycO9l4NJmUsj%2FRKN3OI6Z%2FWs%3D)![Main form calculation using sumSubform function to total subform values](https://cdn.document360.io/dd260e4e-10bb-4b66-8fb3-5504c272b904/Images/Documentation/115003453671?sv=2026-02-06&spr=https&st=2026-10-30T07%3A21%3A10Z&se=2026-10-30T08%3A21%3A10Z&sr=c&sp=r&sig=DUFGyKYHplZxqRLHScdycO9l4NJmUsj%2FRKN3OI6Z%2FWs%3D) - Make sure to keep the **$** signs on the outside of your field key. 7. Replace **'fieldkey'** with the field that you want to add/sum across your subform instances (ours is *'computedlabel_3'*). - It is important to use **single quotes** (**'**) for this part instead of using $ signs. 8. **Save** and **publish** your form.