Cognito Forms – How the Calculated Field Feature Works

cognito-forms

I am asking this question on behalf of Chris Kennedy, who posted this question to Facebook.

Is there any documentation for the calculate feature? I would like to be able to have add a price based on a y/n question.

Best Answer

EDIT: Our calculation documentation is now available at https://www.cognitoforms.com/support/2/calculations.

We are actively working on documentation for calculations as part of our release this week of conditionally visible fields/sections and conditionally required fields. However, since the documentation is not yet public I will provide a brief answer now that is a bit technical and update the answer once our documentation is public.

First off, always start calculations by typing = into the field. We support calculations for a lot of different fields, such as default value, so the = let's us know you are trying to perform a calculation versus just entering a literal value.

As soon as you enter the = you will immediately see a menu pop up with statement completion (intellisense, autocomplete, etc.) to help you write your calculation. Also, if you have an invalid calculation, you will see an error message indicating the position of the problem and a "hopefully helpful" error message.

Cognito Forms calculations are very sophisticated, which is one of the reasons why we have not already released the documentation. However, for your task, any normal mathematical expressions will work fine, such as =A*5 + B*2, where A and B are the names of fields on your form. The statement completion will help you out with field names, but generally they are just the labels of the fields without spaces or special characters.

Lastly, our calculations are based on an open source parser created by Microsoft in 2008 called Dynamic Linq. If you need more help in the short term and are technically minded, check out Scott Guthrie's post, download the sample zip and read the full documentation under LinqSamples\DynamicQuery. After reading this documentation you will see why we are taking our time creating documentation that is more approachable for less technical audiences.

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx