Tuesday, December 18, 2012

Lesson 6: Working with expressions in SSRS (Tutorial)


Click on Report in menu bar and select Report Properties.




















You will get the below dialog box.


















Navigate to the Code tab and type the below function. Click Ok. 

Public Shared Function SetColor(ByVal TicketPrice As Integer) As String
SetColor= "Transparent"
If TicketPrice >= 200 Then
SetColor= "Green"
End IF 

End Function


















Right click on Price column and select the text box properties option.




















In the text box properties dialog window, navigate to Fill tab and click function button.





















Type below code in the Expressions window. 
=Code.SetColor(Fields!Price.Value)





















Preview the report.























Type below functions in the report properties window as in earlier step. 

'Function to set the font weight as bold
Public Shared Function SetBoldFontWeight(ByVal TicketPrice As Integer) As String
SetBoldFontWeight= "Default"
If TicketPrice >= 200 Then
SetBoldFontWeight= "Bold"
End IF
End Function


'Function to set the font weight as italic
Public Shared Function SetItalicFontWeight(ByVal TicketPrice As Integer) As String
SetItalicFontWeight= "Default"
If TicketPrice >= 200 Then
SetItalicFontWeight= "Italic"
End IF 

End Function


















Right click on Title column and select the text box properties option.
















In text box properties, navigate to Font tab. Click the expression button for Bold and type the below code in expressions dialog window. 

=Code.SetBoldFontWeight(Fields!Price.Value)






















Next click the expression button for Italic and type the below code in expressions dialog window. =Code.SetItalicFontWeight(Fields!Price.Value)



















Preview the report.






















Conclusion:

No comments:

Post a Comment