SSRS Custom Code Case Statement

Anita75 26 Reputation points
2020-12-02T20:10:32.727+00:00

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 Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,035 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,704 questions
0 comments No comments
{count} votes

Accepted answer
  1. Joyzhao-MSFT 15,621 Reputation points
    2020-12-03T08:06:52.15+00:00

    Hi @Anita75 ,
    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

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Viorel 121.3K Reputation points
    2020-12-03T07:17:41.357+00:00

    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
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.