Skip to content

Instantly share code, notes, and snippets.

@samteezy
Created April 19, 2018 19:57
Show Gist options
  • Select an option

  • Save samteezy/b1729238ce9a4dfa9153777a46a21dfa to your computer and use it in GitHub Desktop.

Select an option

Save samteezy/b1729238ce9a4dfa9153777a46a21dfa to your computer and use it in GitHub Desktop.
Formula field to format currency values properly in a text field
IF(
CurrencyField__c>= 1000000,
TEXT(FLOOR(CurrencyField__c / 1000000)) & ",",
"") &
IF(
CurrencyField__c >= 1000,
RIGHT(TEXT(FLOOR(CurrencyField__c / 1000)), 3) & ",",
"") &
RIGHT(TEXT(FLOOR(CurrencyField__c)), 3) & "." &
IF(
MOD(CurrencyField__c , 1) * 100 > 0,RPAD(TEXT(ROUND(MOD(CurrencyField__c , 1), 2) * 100),2,"0"),
RPAD(TEXT(MIN(ROUND(MOD(CurrencyField__c , 1), 2) * 100, 99)),2,"0")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment