I'm using SQL Server 2014 Reporting Services to display matrix with dynamic data in the following manner:
- Data for report resides in a database view, where one record has >20 id/name attributes (e.g. CityID, CityName, CountryID, CountryName, SalesmanID, SalesmanName, ProductID, ProductName, Index1ID, Index1Name, Index2ID, Index2Name...) and 2 decimal values (Value1, Value2)
- SSRS report has exactly one matrix (tablix)
- User specifies what data to put in the tablix columns "domain" and what data to put on the rows "domain" (e.g. user selects parameters columns: Product, and rows: City)
- Tablix value shows aggregated Value1 and Value2
This dynamic feature works by using expressions in the group definition. In the "Group on" field I used an expression like this:
=Switch(
Parameters!XAxisDimensionParameter.Value=1, Fields!CityId.Value,
Parameters!XAxisDimensionParameter.Value=2, Fields!CodeId.Value,
Parameters!XAxisDimensionParameter.Value=3, Fields!NameId.Value,
Parameters!XAxisDimensionParameter.Value=4, ...,
..., ...,
)
What I would now like to do is to add a grouping functionality to rows. User would enter e.g. "Country,Region,City" in the "Group by" parameter and the tablix would group Products data by CountryID, RegionID and CityID. Pay attention to the detail that there can be an arbitrary number of grouping specified by the user. No grouping is also a valid option.
I can do this statically in design-time,but it's not the solution for the user requirement.
It looks like it's impossible to dynamically add grouping in the runtime.
Is it really?