close

# Computing Cost in your Apps with Calculation Fields

August 26, 2015

## Computing costs with calculation fields

Since we released calculation fields in Fulcrum a few months back, our users are building them for all sorts of interesting uses for collection in the field. A common use for calculation fields is to build formulas for working with cost numbers—for totaling individual item costs, computing tax amounts, and using total cost results to drive additional form inputs using conditional logic.

We’ve built out a couple of guides to demonstrate how you can use calculation fields to derive costs based on other fields in your data. Our first simple example guide shows how to use the SUM function to add up individual numeric fields using addition expressions. This example also shows how to add a sales tax percentage into the final total

Our second example guide walks through a more advanced scenario involving repeatable sections for adding many “items sold” on a single record. Using the REPEATABLESUM function, the expression used here can total up the amount for each item added in the repeatable section.

If you’re using calculations in your apps, also check out our post with tips and tricks for using calculation fields.

And as a recap of the initial calculation fields post:

Adding calculated fields to your apps allows you to write simple expressions to calculate values dynamically based on input given to other fields in your forms. As you can see from the example video below, when you build an expression using a calculated field, you have access to all of your form field values from within the expression builder tool for driving calculations. There’s an extensive library of searchable functions, most of which you’ll recognize if you’re familiar with building formulas in spreadsheets like Excel or Google Sheets. Also included are several functions that are Fulcrum data-specific, giving you the ability to include in your calculations your record’s statuslatitude or longitude, and more.

This is going to enable dozens of new ways to deal with data while in the field, and output useful results to your field staff:

• Calculation of dimensions, areas, and volumes for site surveys
• Determining totals for supply and inventory applications
• Weighting and averaging for dynamic scoring
• Displaying summary text with concatenation

For users wanting to calculate more complex results from their data, calculated field expressions can be written in Javascript. This means you can write complex functions (and entire programs) to spin results out of user-entered data on-the-fly.

Calculated fields on all platforms—the web, iOS, and Android— are powered by the same expression interpreter, in an open source library on GitHub, so enterprising technical users can see under the hood at how our expression engine is put to getether.