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:
-
Use a Numeric Variable:
Ensure the input number is of typeDoubleorDecimalto handle both integers and floating-point values. -
Format the Number with Thousands Separator:
Use the.ToStringmethod with the#,##0.00format specifier. This format ensures:- Commas are added as thousand separators.
- Two decimal places are retained (e.g.,
40000.00→40,000.00).
-
UiPath Workflow Example:
- Input Variable:
inputNumber(type:DoubleorDecimal). - Formatted Output Variable:
formattedNumber(type:String). - Assign Activity Code:
formattedNumber = inputNumber.ToString("#,##0.00")
- Input Variable:
-
Examples of Outputs:
- Input:
40000.00→ Output:40,000.00 - Input:
3000→ Output:3,000.00 - Input:
1234567.89→ Output:1,234,567.89
- Input:
Complete UiPath Workflow Example:
- Read Input: Create an input variable (e.g.,
inputNumber). - Format Number:
- Use an
Assignactivity:formattedNumber = inputNumber.ToString("#,##0.00")
- Use an
- Output Result: Display
formattedNumberusing aMessage Boxor write it to a file.
Would you like me to create a visual guide or a sample workflow file for you?