question

Anita75-4652 avatar image
0 Votes"
Anita75-4652 asked Anita75-4652 commented

SSRS Custom Code Case Statement

Hi,
Tried to create a custom code with case statement and its not working. Maybe if else statement is better

Public Function Cur(ByVal as Value As String) As String
Select Case Value
Case "" Return "$ "
Case "AUD" Return "$ "
Case "USD" Return "US$ "
End Select

End Function

sql-server-transact-sqlsql-server-reporting-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Joyzhao-MSFT avatar image
0 Votes"
Joyzhao-MSFT answered Joyzhao-MSFT edited

Hi @Anita75-4652 ,
Try the follow function:

  Public Function Cur(ByVal Value As String) As String
      Select Case Value
         Case is ""
             Return "$ "
         Case is "AUD"
             Return "$ "
         Case is "USD"
             Return "US$ "
         Case Else
             Return Nothing 
      End Select   
  End Function

Regards,
Joy


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
What can I do if my transaction log is full?--- Hot issues November
How to convert Profiler trace into a SQL Server table -- Hot issues November

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Anita75-4652 commented

Check this function:

 Public Function Cur(ByVal Value As String) As String
    
     Select Case Value
         Case "", "AUD"
             Return "$ "
         Case "USD"
             Return "US$ "
         Case Else
             Return "???" ' TODO: throw some error?
     End Select
    
 End Function
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This should work as weel with bit of tweaking thanks

0 Votes 0 ·