Loading

Commas Lost in Text Formula from Currency Field

Publiseringsdato: Oct 22, 2025
Beskrivelse

The TEXT() function removes thousands separators when converting currency fields to text in formulas. This article shows how to add commas back using a CASE formula.

 

Scenario:

For example, if a currency field contains $1,234,567, using TEXT(Amount__c) in a formula returns '1234567' without commas. This formula restores the comma separators.

Løsning

When you set the return data type of a formula field to "Text" and reference a currency field using the TEXT() function, the thousands separator commas (,) that were originally in the currency field are no longer displayed.

For the number converted to text by the TEXT() function, intentionally add thousands separator commas by combining functions such as CASE and LEN.

The following sample formula assumes the number has a maximum of 10 digits. Please replace "*" in the formula with the API name of your target currency field.

Sample Formula:

CASE(LEN( TEXT(*) ) ,
4, LEFT( TEXT(*), 1) & "," & RIGHT( TEXT(*), 3),
5, LEFT( TEXT(*), 2) & "," & RIGHT( TEXT(*), 3),
6, LEFT( TEXT(*), 3) & "," & RIGHT( TEXT(*), 3),
7, LEFT( TEXT(*), 1) & "," & MID( TEXT(*), 2, 3) & "," & RIGHT( TEXT(*), 3) ,
8, LEFT( TEXT(*), 2) & "," & MID( TEXT(*), 3, 3) & "," & RIGHT( TEXT(*), 3),
9, LEFT( TEXT(*), 3) & "," & MID( TEXT(*), 4, 3) & "," & RIGHT( TEXT(*), 3),
10, LEFT( TEXT(*), 1) & "," & MID( TEXT(*), 2, 3) & "," &MID( TEXT(*), 5, 3) & "," & RIGHT( TEXT(*), 3),
TEXT(*))

Formula Explanation: This formula uses the CASE function to branch the process based on the number of digits in the value. For example, it first determines the number of digits of the currency field "*" with LEN( TEXT(*) ). If the number of digits is 4, it gets the first character from the left with LEFT( TEXT(*), 1), concatenates a ,, and then concatenates the three characters from the right with RIGHT( TEXT(*), 3). (e.g., 1000 → 1,000)

For numbers with 5 or more digits, it uses similar logic to adjust the position where the commas are inserted.

Please refer to the following document.

Scope of support for formulas

Flere ressurser

LEN

LEFT

RIGHT

TEXT

MID

Knowledge-artikkelnummer

005132555

 
Laster
Salesforce Help | Article