Calculation

Modified on Mon, 28 Oct at 8:52 AM

The Calculation element allows you to create calculations based on the inputs of elements on the form. Calculations can be performed using the following elements; number, calculation, radio button, checkboxes, select and Date & Time.


For a more hands-on experience with calculations check out this interactive form.


Calculation Element


The calculation element had a few different attributes that you can configure these are broken down below. 



Calculation Input


This is where you create the formula for your calculation adding elements from the form and any math expressions (+ - / * )  


Insert Element


You have the option to directly insert elements from the form allowing you to easily select applicable form elements to add to your calculation formula. Form elements added to the calculation formula are represented as {ELEMENT:element_name} where element_name will be the name of the element you select. 


Rounding


You can round your inputs using the ROUND, ROUND_UP and ROUND_DOWN functions allowing you to round inputs as required. ROUND allows you to adjust the number of decimal places, whereas ROUND_UP and ROUND_DOWN only round to the nearest whole number.


For example, if you wanted to round the input of your currency element to 2 decimal places you would use:

ROUND({ELEMENT:element_name}, 2)




Null Values


You are able to have calculations with Null Values. Meaning the calculation can run without the need for all the calculation elements to have an input. This can be done using the ISNULL function similar to the ROUND function.

Include the ELEMENT in the {} curly brackets and after the comma add the number you want to use for when the element does not have a value. In the example below the element is treated as having a value of 0 until the user updates the element with an actual value.

ISNULL({ELEMENT:element_name}, 0)


Calculation Content


This is what will be displayed once the calculation has been completed. {RESULT} is where the result of the calculation will appear. You are able to add other text around the result to help add context to the result.


Pre-calculation Content


The pre-calculation content will appear prior to the calculation being run. This can be used to create placeholders text that will be for your results.


Example 


Here you can see the Calculation taking in two number elements, ‘Number_1’ and ‘Number_2’ and adding the two numbers together. 


For the Calculation Content we have added some helpful text before the {RESULT} to explain what is happening in the calculation. This is an optional step the only thing that needs to be displayed here is the result.

 

In the Pre-calculation Content you can see we have added a placeholder to show what will be displayed once the inputs have been completed.



Numbers Elements

Number elements are the most commonly used elements in calculations. In the example below We are summing two number elements and displaying the result. 




Radio Button Elements

Radio buttons are able to be used as in calculation elements by using the value of the select or radio option.






These are the values that will be used in the calculation element when the radio button is selected.

Let's see how this works in practice.


You'll notice that not all ratings have the same effect on the score. 

'Story Telling', and 'Creativity and Originality' have much more of an effect on the score than 'Cinematography' and 'Editing'.

This is due to the value placed on those radio buttons. The value of the 'Engagement' (%20) is double that of the 'Cinematography' (%10) because of how the score is calculated. This can be done through setting appropriate variable, or set in the calculation itself.






Checkboxes

Calculations can also be run using checkboxes. When using a checkbox in a calculation, the calculation will sum all the values selected in the checkbox element. In the example below you can see the one checkbox elements whose checkbox values are being summed together. 



Select Boxes

Select boxes allow the user to calculate by using the Select element. In the example below we are adding the values of 2 different select elements. It is important to note that when using select elements for calculations you must ensure that the value of the list option is a number, similar to the checkbox and radio button elements. 




Dates and Times


Date and Time elements can be used in calculations. They are inserted into a calculation element and can be used for a variety of circumstances. Some examples are Calculating the time difference between days or how much time an event took.


Date and Time calculations use Epoch Unix timestamps which are represented as a number, specifically the number of milliseconds since Jan 01 1970 (UTC). Meaning when calculating the difference between times you will need to divide the result in order to get the increment of time your are looking for. For example in Example 1 below, the result is measured in hours, so the difference between the end and start times is divided by 3,600,000 (the number of milliseconds in 1 hour).


Example 1 (Time Calculator)


In this example we are calculating the difference between a start time and an end time between these different times within a day the result displays the amount of time in hours.




Example 2 (Dates Calculator)


In this example, we are starting with a start date and an end date and calculating the amount of time between these different dates to display the amount of time in days as a result.



Example 3 (Date and Time Calculator)


In this example we are calculating the difference in time between 2 different dats as well as the addition of times within a day, this calculation displays the amount of time in days and time.




Additional Examples


Here are some other simple examples for how the calculation elements can be used. 



Ordering Form


Here we are taking this to the next step by creating a simple ordering form. We have added some products (milk and eggs), and attached price modifiers. 

Now when the user inputs the number of that specific item they want the calculation will add that to the total. 



Fuel Cost Calculator


Here we are taking a few more inputs and adding a second calculation element, instead of doing the entire calculation in one calculation element.



Getting Help

If you need any assistance with Calculations please reach out through the Report Issue menu or email support@oneblink.io. 




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article