Showing posts with label SSRS Functions. Show all posts
Showing posts with label SSRS Functions. Show all posts

Friday, April 25, 2025

Enhancing Readability of Custom Report Fields Using SSRS Expressions (Switch case)

 Hi Everyone,

I have received a custom report where one of the fields displays non-readable strings based on different processing levels. To improve clarity, I need to convert these codes into meaningful descriptions. To achieve this, I'm utilizing the Switch function within the SSRS report field expressions.

=Switch(

    Fields!Name.Value = "Step1", "L1 Team Review",

    Fields!Name.Value = "Step2", "L2 Team Review",

    Fields!Name.Value = "Step3", "L3 Team Review"

)

In this expression, when the Name field has a specific value (e.g., "Step1"), it displays the corresponding descriptive text ("L1 Team Review"). If none of the specified conditions are met, the expression returns Nothing by default.​

Handling Unmatched Values:

To display the original value when it doesn't match any specified condition, you can add a default case using True as the final condition:​

=Switch(

    Fields!Name.Value = "Step1", "L1 Team Review",

    Fields!Name.Value = "Step2", "L2 Team Review",

    Fields!Name.Value = "Step3", "L3 Team Review",

    True, Fields!Name.Value

)

This approach ensures that if the Name field's value doesn't match any of the specified cases, the original value is displayed. This technique is commonly used in SSRS to provide a default case in Switch expressions. ​

Note on Single Value Replacement:

For replacing a single value, the Replace function can be used:​

=Replace(Fields!Name.Value, "Step1", "L1 Team Review")

However, this method is limited to replacing one value at a time. For multiple replacements, the Switch function is more efficient.​

Additional Considerations:

Handling Null or Empty Values: To prevent errors when the Name field is null or empty, incorporate a check using IsNothing:​

  =IIF(IsNothing(Fields!Name.Value), "No Data", 

      Switch(

          Fields!Name.Value = "Step1", "L1 Team Review",

          Fields!Name.Value = "Step2", "L2 Team Review",

          Fields!Name.Value = "Step3", "L3 Team Review",

          True, Fields!Name.Value

      )

  )

This ensures that if the Name field is null, the expression returns "No Data" instead of causing an error. 

Friday, April 29, 2022

How to display page footer information only on the last page in SSRS

      

Hi Guys,

     it can be challenging to figure out how to display information one time within the page footer on the last page. At the top of the page footer, add a rectangle. Change the hidden property of the rectangle to:

=IIF(Globals!PageNumber=Globals!TotalPages,false,true)


Wednesday, April 6, 2022

Remove time from UTC DateTime data type

 Hi,


how to remove time from the UTC DateTime data type.   I am  using   this  in the  format function  of  SSRS Report  level expression

=Format(Fields!from date.value,"MM/dd/yyyy")