← back to App Design

Simple Cost Calculations

Using calculation fields for simple cost calculations.

This guide will walk through how to compute total cost in a Fulcrum app live in the field using custom calculation fields. From a mobile device, a user can enter the value of multiple separate items and have a calculation field compute the total.

In this example, we have numeric fields for three different items. When the user enters the three monetary values, it’ll compute a total, including an optional sales tax percentage.

Creating the Items and Subtotal

We start out by adding the three numeric fields for our items, with options on those fields to allow only integer amounts, or also decimal entry. A “Subtotal” calculation field then includes the expression to add all of the individual items together. The calculation field expression builder also includes a test input panel to try out your expression before deploying, to make sure it outputs the desired result.

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.

Formula example for addition

Adding Tax

Next there’s a field included for adding sales tax to the subtotal to get a final total value of items. The “Sales Tax” field is numeric, allows decimal input, and also includes a default value so users don’t have to enter a common sales tax amount for each record created, but they can still modify it if needed to recalculate the total on the fly. The “Total” calculation field includes an expression to add the tax percentage on top of the subtotal:

Adding tax to the subtotal

Video Walkthrough

Here’s a quick video overview showing how to build simple cost calculations, 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