Calculations
Value expressions let you auto-generate dynamic values at runtime, based on your specifications. They help you to automate important processes and reduce test design and maintenance efforts.
Calculations let you hand the math over to Tosca Cloud. For example, calculate a total and compare it to what's actually in your table. To perform calculations in your tests, use the expressions CALC or MATH:
-
Use CALC if you have Microsoft Excel 2010 or later installed. Tosca Cloud forwards the calculation to Microsoft Excel, which performs the calculation. This means that you can also use Excel's mathematical functions in your tests.
-
Use MATH if you don't have Excel installed or don't want to use it.
Use CALC
To perform your calculations with CALC, use the syntax {CALC[<Operand 1><Operator><Operand 2>...<Operator><Operand n>]}.
Supported languages
By default, CALC uses English expressions.
You can change the language for your calculations to the local language on your workstation. To do so, add a parameter with the name ExcelLanguage and the value Local.
For both English and local language expressions, make sure that your Microsoft Excel settings match the Windows system settings of your workstation.
Supported operands
You can use any string as an operand.
If your operands contain special characters, you must escape them. Please note that in CALC, Tosca Cloud also considers digit grouping as special characters.
Digit grouping in your calculations.
The syntax {CALC[1000+""""1,000.50""""]} returns the result 2000.50.
Supported operators
CALC supports all Microsoft Excel operators and processes them according to Microsoft Excel rules.
Operator processing in your calculations.
-
The syntax {CALC[2*2+5]} returns the result 9. It first calculates 2 x 2 and then adds 5.
-
The syntax {CALC[2*(2+5)]} returns the result 14. It first calculates 2 + 5 and then multiplies this result by 2.
CALC combinations
You can combine CALC with any of the following:
-
All mathematical functions supported by Microsoft Excel
Include a variable called Example, which has the value 2000.
The syntax {CALC[1000+""""{B[Example]}""""]} returns the result 3000.
Use the Excel function FIXED (opens in new tab).
The syntax {CALC[FIXED(5000/3, 1, True)]} returns 1666.7:
-
It divides 5000 by 3.
-
It returns the result with one decimal.
-
It doesn't include thousands commas.
Use multiple functions and a variable called Example with the value Tricentis Tosca.
The syntax {CALC[RIGHT(""""{B[Example]}"""",LEN(""""{B[Example]}"""")-FIND(""" """,""""{B[Example]}""""))]} returns Tosca.
It takes the rightmost characters of the full length of the character string until it finds a space.
Use MATH
To perform your calculations with MATH, use the syntax {MATH[<Operand 1><Operator><Operand 2>...<Operator><Operand n>]}.
Supported languages and number formats
MATH uses English expressions.
Supported operands
You can use numerical values or scientific notations.
Supported operators
MATH processes operators in the same way as Microsoft Excel.

MATH supports the following operators:
Operator |
Description |
---|---|
+, -, *, / |
Basic arithmetic operations |
% |
Modulo operation |
== |
equals |
!= |
does not equal |
&& |
AND operation for two items |
|| |
OR operation for two items |
< |
less than |
> |
greater than |
<= |
less or equal |
>= |
greater or equal |
&, |, ^, <<, >> |
Bit-wise operators: and, or, xor, left shift, right shift |
!, ~ |
Unary operators: not, bit-wise not |
Operator processing in your calculations.
-
The syntax {MATH[2*2+5]} returns the result 9. It first calculates 2 x 2 and then adds 5.
-
The syntax {MATH[2*(2+5)]} returns the result 14. It first calculates 2 + 5 and then multiplies this result by 2.
MATH combinations
You can combine CALC with any of the following:
-
Supported mathematical functions

MATH supports the following functions:
Function |
Description |
Example | Result |
---|---|---|---|
Abs |
Returns the absolute value of a specified number. |
Abs(-1) | 1 |
Ceiling |
Returns the smallest integer greater than or equal to the specified number. |
Ceiling(1.5) | 2 |
Floor |
Returns the largest integer less than or equal to the specified number. |
Floor(1.5) | 1 |
Max |
Returns the larger of two specified numbers. Make sure to specify numbers of the same type. If you mix, for example, integers and float numbers, you get incorrect results. |
Max(1, 2) | 2 |
Min |
Returns the smaller of two numbers. Make sure to specify numbers of the same type. If you mix, for example, integers and float numbers, you get incorrect results. |
Min(1, 2) | 1 |
Pow |
Returns a specified number raised to the specified power. |
Pow(3, 2) | 9 |
Rounds a value according to the IEEE 754 standard (opens in new tab).
|
Round(3.1234, 2) | 3.12 | |
Sign |
Returns a value that indicates the sign of a number:
|
Sign(-349) | -1 |
Sqrt |
Returns the square root of a specified number. |
Sqrt(4) | 2 |
Truncate |
Truncates the decimal places of a value. |
Truncate(1.7) | 1 |
Include a variable called Example, which has the value 2000.
The syntax {MATH[1000+{B[Example]}]} returns the result 3000.
Use the mathematical function Round.
The syntax {MATH[Round(2.15,1)]} returns the result 2,2.