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"))
4 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

Hello,

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

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

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

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