For Dynamic Sorting SSRS has Interactive Sorting which enables a sorting button on the Tablix Column and user can sort on desired Column but many time user wants to have Drop-Down or Combo Box listing columns and wish to chose the sorting column from there.. Something like
Okay , this is not built-in feature of SSRS but we can certainly work around and provide that feature... I will take a simple example to demonstrate that: I will create a Simple Student table and provide drop down sorting on the columns in the table.
So Lets get started
1. Create a Student table
2. Create a SSRS project and create a Shared DataSource linking our Database
3. Create a simple report having columns from Student table
4. Report would look like.
5a. Now lets start our work and create a parameter SortBy
5b. Specify Available values as Column name from the Student table and assign values to them
6. Go to Tablix Properties> Sorting
7.Add a sorting Option and in Column tab give expression as
=IIf(Parameters!SortBy.Value=1,Fields!StudentID.Value
,IIf(Parameters!SortBy.Value=2,Fields!Name.Value
,Fields!Marks.Value))
8. Run the report and chose the SortBy column from Drop-Down
a. By Name
b.By Marks
Cheers-Have fun!!
Rahul Sherawat
No comments:
Post a Comment