Our scoring & calculations feature is like having a silent math whiz hidden in your forms, tallying scores and calculating totals faster than you can say "Where’s my abacus?".

Whether you’re summing up patient satisfaction scores or automating the tally for that lengthy health questionnaire, these new features are about to be the MVP of your clinic’s paperwork game.

# What it looks like

Here's part of an FABQ Form as an example, showing a score being generated dynamically after answering the first section:

# Creating a score

There are a few components to creating a score that can be inserted into a Form:

Some numerical values to tally up

One or more

*calculation*fields to do the tallyingOne or more @placeholder mentions to insert the scores into the Form

## The numerical values

In the FABQ example above, each screen contains one field configured with six different buttons. Here's what that screen looks like in the Form Editor:

Clicking the *Change options* button will show both the display values of the option, and the *raw* value. The raw value is the value *behind* the option. This is what's used in calculations. Let's see that now:

As you can see, all raw values are *numeric* in nature. This is important. Only fields configured with *all numeric values *behind their options can be used in calculations.

## The calculation field

The numeric *raw* values are useless without a way to use them. The *calculation *field type is what we use to perform calculations on our numeric values. Here's the calculation field we used in the FABQ example above:

Calculation fields operate similarly to formulas in excel. In this example, we define a calculation using the *sum* function to add together the results of questions 2, 3, 4 and 5 (which will each have a value of 0-6).

This type of field looks different to a field of any other type in the editor. We'll get into why later.

## The @placeholder mention

The final piece of the puzzle is the @placeholder mention. This is a way to *reference* a calculation field later on in the form. Here's the screen definition for the FABQ example above:

Notice that the placeholder is defined as @FABQpa, which corresponds to the value in the field prompt of the calculation field.

## Bonus: Visibility logic

A fourth part — bet you didn't see that coming! 😅 One of the most powerful parts of using calculation fields in your Form is that you can use them inside Visibility logic to show or hide parts of the Form based on previous calculations. You might have noticed that, in the video above, only that first field was displayed.

That's because we defined Visibility logic to show the first field only if the score was over 15, and the second field to show only if the score was under 16:

# Diving deeper

Scoring & calculations are one of the most complicated parts of a Finger-Ink Form. You've probably got more questions. Let's have a go at answering them before they're asked.

## What functions are available to use in calculation fields?

The available functions for calculations are **count**, **sum**, **average**, **min** & **max**.

Count — counts all the number of selected options on a field. This is only really useful for fields allowing you to select

*more*than one option at a time. This is the only exception to the rule that requires all numeric raw values.Sum — adds all the raw values for the option(s) for the specified field(s).

Average — does a sum first, then divides the answer by the number of values present.

Min — takes the smallest value in the given list.

Max — takes the largest value in the given list.

Here's an example using sum on 3 different fields:

`sum([ @field1, @field2, @field3 ])`

☝️ Notice both the parentheses and square brackets — both are required.

## Are calculation fields displayed during Form filling?

🚫 No. Calculation fields are not displayed during Form filling. They even have an "always hidden" indicator beside their label:

## Can I define a calculation field anywhere in my Form?

🚫 No. Calculation fields, being fields, can only be defined within a Screen.

Furthermore, calculation fields need to be defined *after* all the values you're wanting to use in the calculation. Here's an example:

## Can calculation fields be used in other calculation fields?

✅ Yes! You can use the result of one calculation in another calculation. This is the recommended approach for sub-totals and totals where the calculations required call for more than just addition.