Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4155
Varying currency format in Infragistics.Report.Label
posted

I have a decimal value i need varying places of precision to be displayed in the PDF i create using Reporting.  If the value is 1.3800, i need to display $1.38.  However, if the value is 1.3833, I need to display $1.38.  How can i format as currency AND yet allow the value to show up to four digits after the decimal, but also truncate to only 2 if the value contains the two trailing zeros?  Obviously I can't simply set the Label->Text->FormatString to c2, because this will not show the 3rd and 4th places if they are other than zero.  Basically I just need to truncate to 2 digits ONLY when the digits are not zeroes, and then show the $ sign etc.  I also need to show empty string if the value is equal to zero.  Here's what I have so far:

=If(Fields.CalcBillingRate<>0,(Format("${0}", Fields.CalcBillingRate)),"")

which works fine except it doesn't truncate the value to two places when the value is, for example, 2.0000 (should show $2.00)

Parents
  • 34810
    Verified Answer
    Offline posted

    Hello Travis,

    Currently, I'm not sure this could be done through the report with the built-in reporting functionality, but I do believe it can be done if you do it through your data. I would recommend adding a bool property to each data item of your underlying data source that you can use in your If statement for formatting the values. You could determine this bool value by parsing your CalcBillingRate property for each data item and setting it to true or false based on whether the Format should be set to allow 4 decimal points or 2. Then, you could use the if statement to check your Fields.Bool property for true or false and set the formatting accordingly.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Developer Support Engineer I
    Infragistics Inc.
    www.infragistics.com/support

Reply Children