report-builder2.0

How can I dynamically format currency fields in report builder?


I have a report where I want to display various amounts of money that can be in many different currencies. My query provides me with the currency symbol and three letter country code (eg GBP or USD) for each value, but I do not have the country ISO code.

How can I format the value expression to use the correct currency symbol?

I cannot simply put the currency symbol in front of the value as some values can be negative, so I would want the minus sign to come before the currency symbol.


Solution

  • I put together some custom code to do this:

    Public Function Currency(ByVal s As String,ByVal a As Double) As String
     Dim r As String
      If a < 0 Then
          r = "(" + s + FORMAT(-1*a,"#,0.00") + ")"
      ElseIf a = 0
          r = "-"
      Else
          r = s + FORMAT(a,"#,0.00")
    End If
    Return r
    End Function
    

    Here I am passing in the currency symbol as s and the amount as a