# Formula

The extra element "Formula" can be used to create online calculators, calculate prices, as well as to calculate scores in tests. To add the "Formula" element to your form, go to the "Extra" elements in the form settings and you need to click on the selected "Formula" item or drag it to the right, then you will see the added element on the right: After you have added the "Formula" element, click on the "Edit" icon and a pop-up window for editing this element will open in front of you: In the "Prefix" field, you can enter the characters that will be output before the result of calculating the formula. In the "Suffix" field, you can enter the characters that will be output after the result of calculating the formula: The following "Separator" field allows you to choose the display of numbers (for example, the amount to be deduced) in the form that you think is more correct for perception: To make some calculations, you need to add certain fields to the form that will directly participate in the calculation formula. To enter the formula settings, click on the item of the same name: A pop-up window with formula settings will open in front of you: Before that, I added a few simple elements that will participate in the formula: In the calculation formula settings, click on the "Add element" icon and a window with elements in the form will open To multiply two elements, first select the "Width" field and add the "multiply" sign: Next, add the second field "Height": As a result, we can simply calculate the area: You can also add various conditions to the formula by clicking on the "Logical condition" icon: A condition will appear in the formula and click "Setup": A window opens where click on the "Add expression" icon: Next, the field for which you need to set the condition and specify the corresponding values: For detailed instructions on creating an online calculator, you can see here.

The following functions are available in the "Formula" element:

• exchangeRates() Converts a number from one currency to another
• round() Returns a number rounded to the nearest whole
• ceil() Rounds the number to the nearest bigger whole
• floor() Rounds the number to the nearest smaller whole
• roundUp() Rounds a number to the nearest multiple of a given number
• min() Returns the smallest of several numbers
• max() Returns the largest of several numbers
• medium() Returns the average of several numbers
• today() Returns the number of seconds from the current date
• datetime() Returns the number of seconds from the current date and time
• strlen() Returns the number of characters in a string
• pow() Raise the number to a degree
• ln() Natural logarithm
• lg() Decimal logarithm
• log() Logarithm of a number on any basis
• sin() Sinus angle in radians
• cos() Cosine angle in radians
• tan() Tangent angle in radians
• ctg() Cotangent angle in radians
• mod() The remainder of the division of two numbers
• countYears() Returns the number of years from the difference of two dates
• countMonths() Returns the number of months from the difference of two dates
• countDays() Returns the number of days from the difference of two dates
• year() Extracts the year from the date
• month() Extracts the month from the date
• day() Extracts the day from the date
• countRemainingDays() Returns the number of days remaining from the difference of two dates
• countRemainingMonths() Returns the number of months remaining from the difference of two dates
• date() Returns the number of seconds from the date from the parameters passed (year, month, day)
• dateValue() Returns the total of all digits of the date

To choose to use the required function in the calculation, click the "Add function" button: A list of available functions opens: For example, let's choose the function max(), which returns the largest of several numbers. After adding the function to the calculation formula, the value (1,2) will appear: Here you need to specify the fields among which the largest value will be selected: In the strlen() function, you can specify, for example, a text field where the function will count the number of characters entered. To do this, click between the brackets: And click add item and select the required field from the list: 