# Learn Calculation Fields Through Examples

June 7, 2016 by Coleman McCormick

Calculation fields are powerful for form customization and used heavily by many Fulcrum users. Since their launch last year, we’ve seen adoption take off and customers are now using them in thousands of different ways.

If you haven’t seen it before, our developers site has in-depth documentation on the various expressions available within the Fulcrum calculation field builder. In addition to this, we’ve created a library of examples that show common use cases for calculation expressions, with code snippets you can copy and paste to learn and use within your own Fulcrum apps.

Let’s take a look at a handful of the useful examples from our library:

Calculate the amount of elapsed time between two dates

If your survey has two separate dates, like a “Permit Expiration Date” and “Today’s Date”, this expression takes two date values and returns the amount of time elapsed between the two:

Populate the day of the week from a date field

This quick formula takes a date field value as input and returns the day of the week:

Sum of numbers within child records

This one shows how you can total up values across repeatable (child) record values. An example if where this would be useful is if your repeatable section represents “materials required”, where each item has a dollar value (like on a bill of materials), you could sum up the total value of all items:

Generate a star rating from a numeric field between 1 and 5

Your first dose of egregious symbol / emoji usage in a calculation field, this sample shows how to swap boring numeric scoring into cooler-looking star ratings:

Totaling scores across child records

And here, if we have child items that each have a “score” field, with a picklist of values like “N/A, 0, 1, 2, 3”, etc. This formula will look through all of the items and sum up the total across all of the subrecords:

Naturally the possibilities for how data-driven expressions can be used for data capture are limitless — especially when chaining the result of one expression into another. Our developer docs are open source on GitHub, so anyone can contribute their own expression examples if you’ve got something you find useful.

• Subscribe: