How to round number to thousand

To handle your use case in UiPath, where numbers of varying lengths need to be formatted with a thousand separator while preserving decimal points, you can use the following approach:

Steps:

  1. Use a Numeric Variable:
    Ensure the input number is of type Double or Decimal to handle both integers and floating-point values.

  2. Format the Number with Thousands Separator:
    Use the .ToString method with the #,##0.00 format specifier. This format ensures:

    • Commas are added as thousand separators.
    • Two decimal places are retained (e.g., 40000.0040,000.00).
  3. UiPath Workflow Example:

    • Input Variable: inputNumber (type: Double or Decimal).
    • Formatted Output Variable: formattedNumber (type: String).
    • Assign Activity Code:
      formattedNumber = inputNumber.ToString("#,##0.00")
      
  4. Examples of Outputs:

    • Input: 40000.00 → Output: 40,000.00
    • Input: 3000 → Output: 3,000.00
    • Input: 1234567.89 → Output: 1,234,567.89

Complete UiPath Workflow Example:

  1. Read Input: Create an input variable (e.g., inputNumber).
  2. Format Number:
    • Use an Assign activity:
      formattedNumber = inputNumber.ToString("#,##0.00")
      
  3. Output Result: Display formattedNumber using a Message Box or write it to a file.

Would you like me to create a visual guide or a sample workflow file for you?