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:

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.

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:

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.