The Basics of the Calculation Field
There are a few things that are necessary to explain before we get into writing some basic calculations. Lets nail down a few terms.
Field - A Field is generally defined as an area where a question is asked and an answer is requested (can also be required) from the person filling out the form. In FastField we have 26 different field types where you can use questions combined with the correct field type to gather specific and relevant data. Fields are designed to make collecting data quicker, easier and more efficient. For example: Think of a paper form where the date needs to be filled out on the top right hand corner. How are you supposed to format the date? Do I separate the day month and year with slashes, dots or commas? Do I include the full four digit year or just two digits? What if the person is from a different country and they use different formatting? What if the person has sloppy hand writing or messed up and it is no longer legible? Or better yet, what if they don't fill it out at all - Now think of a digital form, where you can simply select the date from a calendar. It automatically populates the date with the correct formatting. I think we would all agree that this is a much simpler, quicker way of collecting relevant and accurate data.
Note: You can find a list of all of the Fields with descriptions here: https://mergemobile.zendesk.com/hc/en-us/articles/202221843-Field-Type-Overview
Field key - A Field key is a unique identification number for a field in your form. When you add a Text field to your form for the first time you will see in that fields settings that there is a little “Field Key” box, with a word “alpha_number” The “alpha” is describing what type of field it is, and the “_number” is associated to the order in which the field was added to your form. Feel free to change these field keys to whatever you would like, you just have to make sure that the key (combination of letters, numbers and symbols) is unique from every other field in the form you are working on. When calculating fields you will never refer to a field with the field label; You will always be calculating with the field key.
Note: There are a few rules for making fieldkeys. There cannot be any spaces in your key, and it has to be a combination of at least one number, and one letter.
- Score - The term “Score” will generally only come into play when calculating selections within a List Field (list, options list, global list, lookup list). You can apply a numeric value to a selection item within your List so that when the user makes that selection, it can be calculated with another field.
- Data - Refers to the input of numbers, letters, words, and symbols as the “Answer” to a specific Field by a user. “Data” can be a general term for a grouping of answers, or it can refer to a single collected answer. Often times we specify “Collected Data” just to be extra clear that this came from a user filling out and submitting a Form.
How it works
Think of the Calculation field as a vehicle engine. An engine is designed from the ground up to operate well if the correct parts are installed in the correct places. In the same way, the calculation field has been built from the ground up to have the correct formulas and components installed in the correct places. Simple calculations, once the basics have been learned, are really easy to put together.
The “$” symbol is an important part of performing calculations in the Calculation field. The “$” symbol essentially tells the Calculation field that the very next set of numbers, letters, symbols is a field key, and it will continue to do so until you end with another $. Think of it like a set of book ends. A pair of book ends on a bookshelf support a set of books in between. In the same way the $ sign supports your field key in the midst of a Calculation. So your field key should looks something like this when placed into the Calculation field:
$numeric_1$ or $StartTime$ or $customerName001$
In the first example “numeric_1” is your unique field key. The first “$” tells the Calculation to “START reading unique field key!” and the end “$” is telling it to “STOP reading unique field key!”.
NOTE: The Calculation field specifically pulls the COLLECTED data from the fields you designate with a field key in your form. Similarly, if a “Default Value” is set in your form, the Calculation field will pull that value as the collected data, unless changed.