Format a number as currency

Jay McCormack asked on June 29, 2015 12:41

Hi

I'm looking for a way to present a decimal value from a custom table in a transformation in currency format.

Currently the transformation simply outputs:

8765678.0000

However I want it to format as:

$8,765,678

I can't believe I'm struggling so hard to make this work. Any suggestions appreciated.

Correct Answer

Dawid Jachnik answered on June 29, 2015 13:38

Hello Jay,

Did you try this ?

string.Format("${0:#,##0.00}", Eval<double>("Number"))
5 votesVote for this answer Unmark Correct answer

Recent Answers


Joshua Adams answered on June 29, 2015 15:01

Is it a text/xml transformation or the ascx. If its ascx, the suggestion above should work fine. Otherwise, look at the macro documentation and there should be something to format a currency. If not, then you can create a custom macro that returns the formatted string.

0 votesVote for this answer Mark as a Correct answer

Jay McCormack answered on June 30, 2015 00:00

@David thanks for your help.

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on July 30, 2015 15:23 (last edited on December 10, 2019 02:30)

Hello,

using macros (e.g. in the Text/XML transformation) the code is actually the same:

{% String.FormatString("${0:#,##0.00}", 8765678.0000) |(identity)GlobalAdministrator%}

Best regards,
Jan Hermann

1 votesVote for this answer Mark as a Correct answer

Rob Chipman answered on March 8, 2017 14:31 (last edited on March 8, 2017 14:53)

Hello

The code that was suggested is the same that I have on my site and it works perfectly but this is for the formatting of numbers to English currency. What is the string for French so that the result is (for example) 876,567 $

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.