Sunday, July 23, 2023

SSRS - How to dynamically change Series to Category & Category to Series in SSRS Chart(s)

If there is a requirement of dynamically changing of Series to Category & Series to Category in Column or bar Chart then it can be achive by using report parameter & SSRS expression. 

Scanario: 
Below is the sample Column Chart report which shows Region & year wise sales information with 
1) Region as Series
2) Year is as Category

We can change this dynamically to below:
1) Year as Series
2) Category is as Category
     

Following are the steps to convert Series to Category & Category to Series in Column Chart:
1. Create a parameter named "Series" and put the value as Region & Year
    


2. Now go to the chart and change the expression for Series and Category

3. For Series - use the below expression
=IIF(Parameters!Series.Value = "Year",  Fields!Year.Value,Fields!Region.Value)
Change this expression for Series Group, Sorting, & Label
 

4. For Category - use the below expression
=IIF(Parameters!Series.Value = "Year",  Fields!Region.Value,Fields!Year.Value)
Change this expression for Category Group, Sorting, & Label
 

5) Now Run the report. select Series as Region and preview
     


6) Now Run the report. select Series as Year and preview
    

Conclusion: We can dynamically change Series to Category & Category to Series in SSRS Chart using report parameter & expression.

No comments:

Post a Comment