I want a interactive sorting in SSRS matrix report. From database we are getting 3 columns -PrimaryKey,Columns and Value.
We are grouping rows by Primary Key and grouping column by Columns and use Value as data.
My Matrix Report -
ID [Columns]
[Primary Key] Values
Output of the Matrix report -
ID FirstName MiddleName Lastname
1 Rajiv Jha Sharma
2 Prem Kumar Bose
3 Usha Shamila Praveena
I am able to use the interactive sorting on ID because ID is group by rows but I want to use the interactive sorting on dynamic cloumns values like FirstName,MiddleName and LastName.
Expected result when we interactive sort on Lastname
ID FirstName MiddleName Lastname
2 Prem Kumar Bose
3 Usha Shamila Praveena
1 Rajiv Jha Sharma
Thanks for any Help.
Are you using the report wizard to build this? You should be able apply the interactive sort using the properties menu on the column groups.
By adding an interactive sort button to a column header you can allow a user to click the column header and sort the parent group rows in a table or matrix by the value displayed in that column. The order of child groups remains unchanged.
To add an interactive sort button to a column header to sort groups:
For more info, see this article: http://technet.microsoft.com/en-us/library/cc627509(v=sql.100).aspx
Quite an old question, but I stumbled upon similar problem recently. Though SSRS does not allow you to add interactive sorting on dynamic columns in a matrix, you can simulate similar behaviour. I've figured out a method, which require the report to fire itself (through go to report action) sorted on desired column.
I will use a bit more complicated example to show the full functionality of this solution. Imagine an online bookstore, which would like a report showing their customers (rows), number of books (values) and total value of books (values), which they bought, by category – Fiction/NonFiction in my example (columns). Of course they want to see their best customers, so the sort will be descending. Example data that we are getting from the database:
The report will look like this:
I would like the report to be able to sort by “Books Count” or “Books Value” for any Column. Here are the steps to follow:
You need to add parameters that will store the name of the column to sort on -
@SortColumn
and the metric name (counts or values) to sort on -@SortMetric
.Go to “Books Count” textbox and add action "Go to report" specifying the same report. Add
@SortColumn
parameter with a value from[Columns]
field in the underlying dataset. Add@SortMetric
parameter with value set to “BooksCount”. Similar for “Books Value” textbox.You can adjust the column header text with following expression, which will show the user on which column data is sorted:
= IIf( Parameters!SortColumn.Value=Fields!Columns.Value And Parameters!SortMetric.Value = "BooksCount" ," ^","")
This was for “Books Count”, you can add similar for “Books Amount”Finally the magic that happens on the database site. Source table is named
[Sales]
. Apart from the sorting, below code allows to select only top N rows if your dataset is larger. You can create a dataset using this code or better create a stored procedure. And join report parameters with dataset parameters.