How to convert a number to have separators and rounding

This can be useful when working with numbers for measurements, currency, pricing, etc.
It limits/ trims the numbers after the separator/ point to 2 decimal places.

The number has to be in a number format and not a string format.

  • Type in a number with the numbers after the decimal point in the Record Generator step.

In the Calculator step, put in the below code.

Copy this code:

inputRecord.number = inputRecord.number.toLocaleString (‘en-US’, {maximumFractionDigits: 2} ) ;

Type in the language code of the language you require in place of en-US.
Then type in the number of decimal places you require after the decimal point in place of the 2.

When running a test after the calculator step, you will see the below number with 2 decimal places.