# Formatting Currency

Does anyone have any suggestions on how to properly format currency in AppGyver?

I’ve searched around and haven’t found any of the currency formatting formulas in AppGyver and am curious how others have gone about this. My challenge is I’m using calculations and sometimes numbers are returned with a long stream of decimals so I need to round or cut off at the hundredths digit, I also need to add the hundredths digit when there is only a tenth decimal, and then add commas when numbers are greater than 1,000.

For example:

Converting \$200.45872 --> \$200.46 or \$200.45
Converting \$2000000 --> \$2,000,000
Converting \$45.3 --> \$45.30

Any suggestions on this are greatly appreciated!

Hi, I think FORMAT_LOCALIZED_DECIMAL() should fit this perfectly. Your Formula would look like this:

``FORMAT_LOCALIZED_DECIMAL(pageVars.amount, "en", 2, 2)``
1 Like

Works perfectly! Thanks for the quick reply @Tomi_Laakso

1 Like

This works great to add commas in the right place and to display the desired number of decimal points. Thanks. But how do you format a number so that in addition to this formatting a “\$” is also displayed in front of the number?

Any response here? This seems like a basic need.

1 Like

So to do that you would need a formula like this
“\$” + pageVars.amount

1 Like

Thank you! That was easy

1 Like

This formula works if you are formatting a TEXT, how about a variable that it value type is NUMBER ?

Any help would be appreciated

Solved: I was not understanding the syntax of the error. I believed that if a variable has already been valued as NUMBER, I didn’t have to do it again in the formula.

But I have an issue using this formula and the result being more than 4 digits, it reverts it to 1, if it’s 5 digits, it only shows 2, if it’s 6 digits, it only shows 3… but if it’s 7 digits, it only shows 1 digit again as a result.

I saw this “bug” or issue in another post, but no one gave a solution.

Thank you for any help

What is your formula, and ill try it on my app?

Before the formatting, the original formula works, but after the formatting, it does the same as this:

Anyone ever have thoughts on handling a negative number with dollar sign?

For anyone else that comes here, I found a workaround to do the following:
REPLACE_ONE(("\$" + FORMAT_LOCALIZED_DECIMAL(current.amount,“en”,2,2)),"\$-","-\$")

Obviously will only work for currencies that use \$, but its a start.