← back to App Design

Advanced Cost Calculations with Repeatables

Using calculation fields for more advanced cost calculations using repeatable section items.

This guide will walk through how to compute total cost in a Fulcrum app live in the field using custom calculation fields, with a slightly more advanced method than our simple example. From a mobile device, a user can enter the value of multiple separate items in a repeatable section and have a calculation field compute the total.

In this example, we have a numeric field within a repeatable section for an item’s value, including other values for an item name, quantity, and a calculation for subtotal of each repeatable item added (value * quantity). Repeatable sections allow you to create many sub-items underneath a single record, which is great for this example of adding X number of items to an individual “Sale” transaction record.

Creating a Repeatable Section for Items

We start out by adding a repeatable section that will allow a user to add any number of items sold to a record for a “sale”. For each item that a user adds, they can enter a title, a unit cost, and a quantity, and the “subtotal” calculation field will multiply the values to get a subtotal.

Formula example for multiplication

With calculation fields, you can also set the display format to make sure the result of your calculation field is set to “Currency” with the specific desired country currency format.

Adding the Items Together

Outside of the repeatable section at the top level, we then add a “Total” calculation field to look at all of the individual items added and sum up their subtotal values. Using the [REPEATABLESUM]() function, the expression will take all of the individual “Item Subtotal” values and add them up.

Using REPEATABLESUM for sum of items

Video Walkthrough

Here’s a quick video overview showing how to build more advanced cost calculations with repeatables, with a demo of a working example on an Android device to show the behavior.

Still have questions? Browse our support forum and drop us a line.

Go to support